From 89da3a5bf7a87bcbc922ed4b57ba26e875807dba Mon Sep 17 00:00:00 2001 From: tianhe1986 Date: Tue, 2 Jan 2018 17:40:56 +0800 Subject: Calling add() after increment/decrement when the return value is FALSE. Signed-off-by: tianhe1986 --- system/libraries/Cache/drivers/Cache_memcached.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'system/libraries/Cache/drivers') 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; } // ------------------------------------------------------------------------ -- cgit v1.2.3-24-g4f1b