summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache
diff options
context:
space:
mode:
authorAndrey Andreev <narf@devilix.net>2018-01-05 16:29:31 +0100
committerGitHub <noreply@github.com>2018-01-05 16:29:31 +0100
commit89bbf356106c0001b2953c156d23b8e939eedac5 (patch)
tree8497d37aa54b3715c66b3ba5b2757bd76f908943 /system/libraries/Cache
parent3b470a6934a030c4bc57ac4c070539b5dd3e13b9 (diff)
parentd77ceeaf3d7c506a050163af40f4a6bb1e1f2a38 (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')
-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 4836b6aed..1562569e8 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -210,7 +210,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;
}
// ------------------------------------------------------------------------
@@ -224,7 +229,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;
}
// ------------------------------------------------------------------------