summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache
diff options
context:
space:
mode:
Diffstat (limited to 'system/libraries/Cache')
-rw-r--r--system/libraries/Cache/drivers/Cache_redis.php31
1 files changed, 25 insertions, 6 deletions
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php
index 3bc3ccd6c..3c4c23d3b 100644
--- a/system/libraries/Cache/drivers/Cache_redis.php
+++ b/system/libraries/Cache/drivers/Cache_redis.php
@@ -69,6 +69,14 @@ class CI_Cache_redis extends CI_Driver
*/
protected $_redis;
+
+ /**
+ * del()/delete() method name depending on phpRedis version
+ *
+ * @var string
+ */
+ protected static $_delete_name;
+
// ------------------------------------------------------------------------
/**
@@ -90,6 +98,10 @@ class CI_Cache_redis extends CI_Driver
return;
}
+ isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('phpredis'), '5', '>=')
+ ? 'del'
+ : 'delete';
+
$CI =& get_instance();
if ($CI->config->load('redis', TRUE, TRUE))
@@ -138,7 +150,7 @@ class CI_Cache_redis extends CI_Driver
{
$data = $this->_redis->hMGet($key, array('__ci_type', '__ci_value'));
- if ( ! isset($data['__ci_type'], $data['__ci_value']) OR $data['__ci_value'] === FALSE)
+ if ($value !== FALSE && $this->_redis->sIsMember('_ci_redis_serialized', $key))
{
return FALSE;
}
@@ -196,9 +208,9 @@ class CI_Cache_redis extends CI_Driver
{
return FALSE;
}
- elseif ($ttl)
+ else
{
- $this->_redis->expireAt($id, time() + $ttl);
+ $this->_redis->sRemove('_ci_redis_serialized', $id);
}
return TRUE;
@@ -214,7 +226,14 @@ class CI_Cache_redis extends CI_Driver
*/
public function delete($key)
{
- return ($this->_redis->delete($key) === 1);
+ if ($this->_redis->{static::$_delete_name}($key) !== 1)
+ {
+ return FALSE;
+ }
+
+ $this->_redis->sRemove('_ci_redis_serialized', $key);
+
+ return TRUE;
}
// ------------------------------------------------------------------------
@@ -228,7 +247,7 @@ class CI_Cache_redis extends CI_Driver
*/
public function increment($id, $offset = 1)
{
- return $this->_redis->hIncrBy($id, 'data', $offset);
+ return $this->_redis->incrBy($id, $offset);
}
// ------------------------------------------------------------------------
@@ -242,7 +261,7 @@ class CI_Cache_redis extends CI_Driver
*/
public function decrement($id, $offset = 1)
{
- return $this->_redis->hIncrBy($id, 'data', -$offset);
+ return $this->_redis->decrBy($id, $offset);
}
// ------------------------------------------------------------------------