1
0
mirror of synced 2024-12-13 22:56:04 +03:00

[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.

This commit is contained in:
guilhermeblanco 2010-03-19 18:09:03 +00:00
parent d24be0b69b
commit 7f7569d983
7 changed files with 11 additions and 11 deletions

View File

@ -70,7 +70,7 @@ abstract class AbstractCache implements Cache
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function save($id, $data, $lifeTime = false) public function save($id, $data, $lifeTime = 0)
{ {
$id = $this->_getNamespacedId($id); $id = $this->_getNamespacedId($id);
return $this->_doSave($id, $data, $lifeTime); return $this->_doSave($id, $data, $lifeTime);

View File

@ -71,9 +71,9 @@ class ApcCache extends AbstractCache
/** /**
* {@inheritdoc} * {@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);
} }
/** /**

View File

@ -70,7 +70,7 @@ class ArrayCache extends AbstractCache
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function _doSave($id, $data, $lifeTime = false) protected function _doSave($id, $data, $lifeTime = 0)
{ {
$this->data[$id] = $data; $this->data[$id] = $data;
return true; return true;

View File

@ -55,10 +55,10 @@ interface Cache
* *
* @param string $id The cache id. * @param string $id The cache id.
* @param string $data The cache entry/data. * @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. * @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. * Deletes a cache entry.

View File

@ -107,9 +107,9 @@ class MemcacheCache extends AbstractCache
/** /**
* {@inheritdoc} * {@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);
} }
/** /**

View File

@ -73,9 +73,9 @@ class XcacheCache extends AbstractCache
/** /**
* {@inheritdoc} * {@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);
} }
/** /**

View File

@ -199,7 +199,7 @@ final class Query extends AbstractQuery
// Cache miss. // Cache miss.
$parser = new Parser($this); $parser = new Parser($this);
$this->_parserResult = $parser->parse(); $this->_parserResult = $parser->parse();
$queryCache->save($hash, $this->_parserResult, null); $queryCache->save($hash, $this->_parserResult, $this->_queryCacheTTL);
} else { } else {
// Cache hit. // Cache hit.
$this->_parserResult = $cached; $this->_parserResult = $cached;