From 7f7569d9831c9679adcf7df3736d380314fe4a74 Mon Sep 17 00:00:00 2001 From: guilhermeblanco Date: Fri, 19 Mar 2010 18:09:03 +0000 Subject: [PATCH] [2.0] Fixed issue with Cache drivers that in some situations they were not storing the entries. Also fixed bug with queryCacheTTL that was not being considered in a Query. --- lib/Doctrine/Common/Cache/AbstractCache.php | 2 +- lib/Doctrine/Common/Cache/ApcCache.php | 4 ++-- lib/Doctrine/Common/Cache/ArrayCache.php | 2 +- lib/Doctrine/Common/Cache/Cache.php | 4 ++-- lib/Doctrine/Common/Cache/MemcacheCache.php | 4 ++-- lib/Doctrine/Common/Cache/XcacheCache.php | 4 ++-- lib/Doctrine/ORM/Query.php | 2 +- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/Doctrine/Common/Cache/AbstractCache.php b/lib/Doctrine/Common/Cache/AbstractCache.php index ab8146b4e..ea5b5df5e 100644 --- a/lib/Doctrine/Common/Cache/AbstractCache.php +++ b/lib/Doctrine/Common/Cache/AbstractCache.php @@ -70,7 +70,7 @@ abstract class AbstractCache implements Cache /** * {@inheritdoc} */ - public function save($id, $data, $lifeTime = false) + public function save($id, $data, $lifeTime = 0) { $id = $this->_getNamespacedId($id); return $this->_doSave($id, $data, $lifeTime); diff --git a/lib/Doctrine/Common/Cache/ApcCache.php b/lib/Doctrine/Common/Cache/ApcCache.php index 0ba3e8a6c..0831a779e 100644 --- a/lib/Doctrine/Common/Cache/ApcCache.php +++ b/lib/Doctrine/Common/Cache/ApcCache.php @@ -71,9 +71,9 @@ class ApcCache extends AbstractCache /** * {@inheritdoc} */ - protected function _doSave($id, $data, $lifeTime = false) + protected function _doSave($id, $data, $lifeTime = 0) { - return (bool) apc_store($id, $data, $lifeTime); + return (bool) apc_store($id, $data, (int) $lifeTime); } /** diff --git a/lib/Doctrine/Common/Cache/ArrayCache.php b/lib/Doctrine/Common/Cache/ArrayCache.php index f9e15b2a6..f4e95aca9 100644 --- a/lib/Doctrine/Common/Cache/ArrayCache.php +++ b/lib/Doctrine/Common/Cache/ArrayCache.php @@ -70,7 +70,7 @@ class ArrayCache extends AbstractCache /** * {@inheritdoc} */ - protected function _doSave($id, $data, $lifeTime = false) + protected function _doSave($id, $data, $lifeTime = 0) { $this->data[$id] = $data; return true; diff --git a/lib/Doctrine/Common/Cache/Cache.php b/lib/Doctrine/Common/Cache/Cache.php index 15e33202c..7bcaa40c8 100644 --- a/lib/Doctrine/Common/Cache/Cache.php +++ b/lib/Doctrine/Common/Cache/Cache.php @@ -55,10 +55,10 @@ interface Cache * * @param string $id The cache id. * @param string $data The cache entry/data. - * @param int $lifeTime The lifetime. If != false, sets a specific lifetime for this cache entry (null => infinite lifeTime). + * @param int $lifeTime The lifetime. If != 0, sets a specific lifetime for this cache entry (0 => infinite lifeTime). * @return boolean TRUE if the entry was successfully stored in the cache, FALSE otherwise. */ - function save($id, $data, $lifeTime = false); + function save($id, $data, $lifeTime = 0); /** * Deletes a cache entry. diff --git a/lib/Doctrine/Common/Cache/MemcacheCache.php b/lib/Doctrine/Common/Cache/MemcacheCache.php index 45a9c0eec..ed1c4bae8 100644 --- a/lib/Doctrine/Common/Cache/MemcacheCache.php +++ b/lib/Doctrine/Common/Cache/MemcacheCache.php @@ -107,9 +107,9 @@ class MemcacheCache extends AbstractCache /** * {@inheritdoc} */ - protected function _doSave($id, $data, $lifeTime = false) + protected function _doSave($id, $data, $lifeTime = 0) { - return $this->_memcache->set($id, $data, 0, $lifeTime ?: 0); + return $this->_memcache->set($id, $data, 0, (int) $lifeTime); } /** diff --git a/lib/Doctrine/Common/Cache/XcacheCache.php b/lib/Doctrine/Common/Cache/XcacheCache.php index 77d05c34b..1ec98502c 100644 --- a/lib/Doctrine/Common/Cache/XcacheCache.php +++ b/lib/Doctrine/Common/Cache/XcacheCache.php @@ -73,9 +73,9 @@ class XcacheCache extends AbstractCache /** * {@inheritdoc} */ - protected function _doSave($id, $data, $lifeTime = false) + protected function _doSave($id, $data, $lifeTime = 0) { - return xcache_set($id, serialize($data), $lifeTime); + return xcache_set($id, serialize($data), (int) $lifeTime); } /** diff --git a/lib/Doctrine/ORM/Query.php b/lib/Doctrine/ORM/Query.php index b12ab1fb6..9e39d1bef 100644 --- a/lib/Doctrine/ORM/Query.php +++ b/lib/Doctrine/ORM/Query.php @@ -199,7 +199,7 @@ final class Query extends AbstractQuery // Cache miss. $parser = new Parser($this); $this->_parserResult = $parser->parse(); - $queryCache->save($hash, $this->_parserResult, null); + $queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL); } else { // Cache hit. $this->_parserResult = $cached;