From d967f7216253d17df0a7154c49303fb560b70e04 Mon Sep 17 00:00:00 2001 From: Tyler Brownell Date: Mon, 29 Jul 2013 19:06:52 -0400 Subject: Cache Log Error Levels The log messages in the cache drvier's is_supported calls are more suited for the debug level. --- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Cache/drivers/Cache_memcached.php') diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 35d91049a..d2a3a489d 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -240,7 +240,7 @@ class CI_Cache_memcached extends CI_Driver { { if ( ! extension_loaded('memcached') && ! extension_loaded('memcache')) { - log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.'); + log_message('debug', 'The Memcached Extension must be loaded to use Memcached Cache.'); return FALSE; } -- cgit v1.2.3-24-g4f1b From 43d7fa73534c07d10a88ec120c0938d0d00a184e Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 9 Jan 2014 17:29:45 +0200 Subject: Implement atomic increment/decrement in Cache library Requested via issue #109 Supersedes PR #241 --- system/libraries/Cache/drivers/Cache_memcached.php | 54 ++++++++++++++++++---- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'system/libraries/Cache/drivers/Cache_memcached.php') diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index d2a3a489d..886357e57 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -60,14 +60,14 @@ class CI_Cache_memcached extends CI_Driver { /** * Fetch from cache * - * @param mixed unique key id - * @return mixed data on success/false on failure + * @param string $id Cache ID + * @return mixed Data on success, FALSE on failure */ public function get($id) { $data = $this->_memcached->get($id); - return is_array($data) ? $data[0] : FALSE; + return is_array($data) ? $data[0] : $data; } // ------------------------------------------------------------------------ @@ -75,20 +75,26 @@ class CI_Cache_memcached extends CI_Driver { /** * Save * - * @param string unique identifier - * @param mixed data being cached - * @param int time to live - * @return bool true on success, false on failure + * @param string $id Cache ID + * @param mixed $data Data being cached + * @param int $ttl Time to live + * @param bool $raw Whether to store the raw value + * @return bool TRUE on success, FALSE on failure */ - public function save($id, $data, $ttl = 60) + public function save($id, $data, $ttl = 60, $raw = FALSE) { + if ($raw !== TRUE) + { + $data = array($data, time, $ttl); + } + if (get_class($this->_memcached) === 'Memcached') { - return $this->_memcached->set($id, array($data, time(), $ttl), $ttl); + return $this->_memcached->set($id, $data, $ttl); } elseif (get_class($this->_memcached) === 'Memcache') { - return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl); + return $this->_memcached->set($id, $data, 0, $ttl); } return FALSE; @@ -109,6 +115,34 @@ class CI_Cache_memcached extends CI_Driver { // ------------------------------------------------------------------------ + /** + * Increment a raw value + * + * @param string $id Cache ID + * @param int $offset Step/value to add + * @return mixed New value on success or FALSE on failure + */ + public function increment($id, $offset = 1) + { + return $this->_memcached->increment($id, $offset); + } + + // ------------------------------------------------------------------------ + + /** + * Decrement a raw value + * + * @param string $id Cache ID + * @param int $offset Step/value to reduce by + * @return mixed New value on success or FALSE on failure + */ + public function decrement($id, $offset = 1) + { + return $this->_memcached->decrement($id, $offset); + } + + // ------------------------------------------------------------------------ + /** * Clean the Cache * -- cgit v1.2.3-24-g4f1b From b2a0e70585367e59bf2d106629c0e9c3ab1370c2 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Sat, 18 Jan 2014 16:54:51 +0200 Subject: Fix #2825 --- system/libraries/Cache/drivers/Cache_memcached.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/libraries/Cache/drivers/Cache_memcached.php') diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php index 886357e57..d59847752 100644 --- a/system/libraries/Cache/drivers/Cache_memcached.php +++ b/system/libraries/Cache/drivers/Cache_memcached.php @@ -85,7 +85,7 @@ class CI_Cache_memcached extends CI_Driver { { if ($raw !== TRUE) { - $data = array($data, time, $ttl); + $data = array($data, time(), $ttl); } if (get_class($this->_memcached) === 'Memcached') -- cgit v1.2.3-24-g4f1b