Commit 7f7569d9 authored by guilhermeblanco's avatar guilhermeblanco

[2.0] Fixed issue with Cache drivers that in some situations they were not...

[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.
parent d24be0b6
...@@ -70,7 +70,7 @@ abstract class AbstractCache implements Cache ...@@ -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);
......
...@@ -71,9 +71,9 @@ class ApcCache extends AbstractCache ...@@ -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);
} }
/** /**
......
...@@ -70,7 +70,7 @@ class ArrayCache extends AbstractCache ...@@ -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;
......
...@@ -55,10 +55,10 @@ interface Cache ...@@ -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.
......
...@@ -107,9 +107,9 @@ class MemcacheCache extends AbstractCache ...@@ -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);
} }
/** /**
......
...@@ -73,9 +73,9 @@ class XcacheCache extends AbstractCache ...@@ -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);
} }
/** /**
......
...@@ -199,7 +199,7 @@ final class Query extends AbstractQuery ...@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment