Author: bicou
Date: 2010-04-10 15:01:40 +0200 (Sat, 10 Apr 2010)
New Revision: 29061
Modified:
plugins/sfRedisPlugin/trunk/lib/Doctrine/Cache/Redis.php
Log:
[sfRedisPlugin] make Doctrine result cache work
Modified: plugins/sfRedisPlugin/trunk/lib/Doctrine/Cache/Redis.php
===================================================================
--- plugins/sfRedisPlugin/trunk/lib/Doctrine/Cache/Redis.php 2010-04-09
15:08:50 UTC (rev 29060)
+++ plugins/sfRedisPlugin/trunk/lib/Doctrine/Cache/Redis.php 2010-04-10
13:01:40 UTC (rev 29061)
@@ -117,7 +117,9 @@
*/
protected function _doFetch($id, $testCacheValidity = true)
{
- return $this->_redis->get($id);
+ $value = $this->_redis->get($id);
+
+ return null === $value ? false : $value;
}
/**
@@ -128,7 +130,7 @@
*/
protected function _doContains($id)
{
- return $this->_redis->exists($id);
+ return $this->_redis->exists($id) ? $this->_redis->get($id.':timestamp') :
false;
}
/**
@@ -143,11 +145,14 @@
protected function _doSave($id, $data, $lifeTime = false)
{
$pipe = $this->_redis->pipeline();
- $pipe->set($id, $data);
+ $pipe->mset(array($id => $data, $id.':timestamp' => time()));
if ($lifeTime) {
$pipe->expire($id, $lifeTime);
+ $pipe->expire($id.':timestamp', $lifeTime);
}
- return $pipe->execute();
+ $reply = $pipe->execute();
+
+ return $reply[0] and (!$lifeTime or ($reply[1] and $reply[2]));
}
/**
@@ -159,7 +164,7 @@
*/
protected function _doDelete($id)
{
- return $this->_redis->delete($id);
+ return $this->_redis->delete($id, $id.':timestamp');
}
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.