From 5f0799aa859914cb6ed4428f023b8f46406218c3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 31 Jul 2014 13:32:41 +0300 Subject: Fix #3161 --- system/libraries/Cache/drivers/Cache_file.php | 12 ++++++++++-- system/libraries/Cache/drivers/Cache_redis.php | 8 ++------ user_guide_src/source/changelog.rst | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/system/libraries/Cache/drivers/Cache_file.php b/system/libraries/Cache/drivers/Cache_file.php index c6aa848fe..aa2e8fa38 100644 --- a/system/libraries/Cache/drivers/Cache_file.php +++ b/system/libraries/Cache/drivers/Cache_file.php @@ -125,7 +125,11 @@ class CI_Cache_file extends CI_Driver { { $data = $this->_get($id); - if ($data === FALSE OR ! is_int($data['data'])) + if ($data === FALSE) + { + $data = array('data' => 0, 'ttl' => 60); + } + elseif ( ! is_int($data['data'])) { return FALSE; } @@ -149,7 +153,11 @@ class CI_Cache_file extends CI_Driver { { $data = $this->_get($id); - if ($data === FALSE OR ! is_int($data['data'])) + if ($data === FALSE) + { + $data = array('data' => 0, 'ttl' => 60); + } + elseif ( ! is_int($data['data'])) { return FALSE; } diff --git a/system/libraries/Cache/drivers/Cache_redis.php b/system/libraries/Cache/drivers/Cache_redis.php index 1c76426c5..7a2b70382 100644 --- a/system/libraries/Cache/drivers/Cache_redis.php +++ b/system/libraries/Cache/drivers/Cache_redis.php @@ -113,9 +113,7 @@ class CI_Cache_redis extends CI_Driver */ public function increment($id, $offset = 1) { - return $this->_redis->exists($id) - ? $this->_redis->incr($id, $offset) - : FALSE; + return $this->_redis->incr($id, $offset); } // ------------------------------------------------------------------------ @@ -129,9 +127,7 @@ class CI_Cache_redis extends CI_Driver */ public function decrement($id, $offset = 1) { - return $this->_redis->exists($id) - ? $this->_redis->decr($id, $offset) - : FALSE; + return $this->_redis->decr($id, $offset); } // ------------------------------------------------------------------------ diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst index d2bb195b6..a1fe4d572 100644 --- a/user_guide_src/source/changelog.rst +++ b/user_guide_src/source/changelog.rst @@ -738,6 +738,7 @@ Bug fixes for 3.0 - Partially fixed a bug (#261) - UTF-8 class method ``clean_string()`` generating log messages and/or not producing the desired result due to an upstream bug in iconv. - Fixed a bug where ``CI_Xmlrpcs::parseRequest()`` could fail if ``$HTTP_RAW_POST_DATA`` is not populated. - Fixed a bug in :doc:`Zip Library ` internal method ``_get_mod_time()`` where it was not parsing result returned by ``filemtime()``. +- Fixed a bug (#3161) - :doc:`Cache Library ` methods `increment()`, `decrement()` didn't auto-create non-existent items when using redis and/or file storage. Version 2.2.0 ============= -- cgit v1.2.3-24-g4f1b