summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/libraries/Cache/drivers/Cache_redis.php27
-rw-r--r--user_guide_src/source/changelog.rst1
2 files changed, 23 insertions, 5 deletions
diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php
index bff96fbfb..b72fb896a 100644
--- a/system/libraries/Cache/drivers/Cache_redis.php
+++ b/system/libraries/Cache/drivers/Cache_redis.php
@@ -83,6 +83,13 @@ class CI_Cache_redis extends CI_Driver
*/
protected static $_delete_name;
+ /**
+ * sRem()/sRemove() method name depending on phpRedis version
+ *
+ * @var string
+ */
+ protected static $_delete_name;
+
// ------------------------------------------------------------------------
/**
@@ -104,9 +111,19 @@ class CI_Cache_redis extends CI_Driver
return;
}
- isset(static::$_delete_name) OR static::$_delete_name = version_compare(phpversion('phpredis'), '5', '>=')
- ? 'del'
- : 'delete';
+ if ( ! isset(static::$_delete_name, static::$_sRemove_name))
+ {
+ if (version_compare(phpversion('phpredis'), '5', '>='))
+ {
+ static::$_delete_name = 'del';
+ static::$_sRemove_name = 'sRem';
+ }
+ else
+ {
+ static::$_delete_name = 'delete';
+ static::$_sRemove_name = 'sRemove';
+ }
+ }
$CI =& get_instance();
@@ -193,7 +210,7 @@ class CI_Cache_redis extends CI_Driver
}
else
{
- $this->_redis->sRemove('_ci_redis_serialized', $id);
+ $this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $id);
}
return $this->_redis->set($id, $data, $ttl);
@@ -214,7 +231,7 @@ class CI_Cache_redis extends CI_Driver
return FALSE;
}
- $this->_redis->sRemove('_ci_redis_serialized', $key);
+ $this->_redis->{static::$_sRemove_name}('_ci_redis_serialized', $key);
return TRUE;
}
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 4d6624a34..cfe9289c4 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -11,6 +11,7 @@ Bug fixes for 3.1.12
====================
- Fixed a bug (#5834) - :doc:`Query Builder <database/query_builder>` method ``count_all_results()`` triggered an SQL error for queries with a ``HAVING`` clause.
+- Fixed a bug (#5840) - :doc:`Cache Library <libraries/caching>` 'redis' driver triggered an ``E_DEPRECATED`` warning about ``sRemove()`` with phpRedis 5.
Version 3.1.11
==============