summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache
diff options
context:
space:
mode:
authortianhe1986 <w1s2j3229@163.com>2018-01-02 10:40:56 +0100
committertianhe1986 <w1s2j3229@163.com>2018-01-02 10:40:56 +0100
commit89da3a5bf7a87bcbc922ed4b57ba26e875807dba (patch)
treea282f9e897ab1a65b108ececa77c0818734c8959 /system/libraries/Cache
parente5af2c34a5af6a6e505034e9af6248131eaf7925 (diff)
Calling add() after increment/decrement when the return value is FALSE.
Signed-off-by: tianhe1986 <w1s2j3229@163.com>
Diffstat (limited to 'system/libraries/Cache')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php18
1 files changed, 14 insertions, 4 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index 314263d7e..cbf874b97 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -210,8 +210,13 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function increment($id, $offset = 1)
{
- $this->_memcached->add($id, 0);
- return $this->_memcached->increment($id, $offset);
+ if (($result = $this->_memcached->increment($id, $offset)) === FALSE)
+ {
+ $this->_memcached->add($id, 0);
+ $result = $this->_memcached->increment($id, $offset);
+ }
+
+ return $result;
}
// ------------------------------------------------------------------------
@@ -225,8 +230,13 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function decrement($id, $offset = 1)
{
- $this->_memcached->add($id, 0);
- return $this->_memcached->decrement($id, $offset);
+ if (($result = $this->_memcached->decrement($id, $offset)) === FALSE)
+ {
+ $this->_memcached->add($id, 0);
+ $result = $this->_memcached->decrement($id, $offset);
+ }
+
+ return $result;
}
// ------------------------------------------------------------------------