summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache/drivers
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2018-01-05 16:29:31 +0100
committerAndrey Andreev <narf@devilix.net>2018-01-05 16:30:23 +0100
commit47df0884591b8678b6873be58b1dc571363e7b28 (patch)
tree8588c676a9095ef414af3d7110dbfbd3aa679aae /system/libraries/Cache/drivers
parentfbe4d79ca0a70f404dce628d66deeaa3d90a2225 (diff)
[ci skip] Merge pull request #5369 from tianhe1986/develop_cache_memcache
Cache_memcached: setting initial value with increment/decrement when not exist
Diffstat (limited to 'system/libraries/Cache/drivers')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b642a2c03..ef020f23e 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -198,7 +198,12 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function increment($id, $offset = 1)
{
- return $this->_memcached->increment($id, $offset);
+ if (($result = $this->_memcached->increment($id, $offset)) === FALSE)
+ {
+ return $this->_memcached->add($id, $offset) ? $offset : FALSE;
+ }
+
+ return $result;
}
// ------------------------------------------------------------------------
@@ -212,7 +217,12 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function decrement($id, $offset = 1)
{
- return $this->_memcached->decrement($id, $offset);
+ if (($result = $this->_memcached->decrement($id, $offset)) === FALSE)
+ {
+ return $this->_memcached->add($id, 0) ? 0 : FALSE;
+ }
+
+ return $result;
}
// ------------------------------------------------------------------------