summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache/drivers/Cache_memcached.php
diff options
context:
space:
mode:
authorBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
committerBrennan Thompson <brenjt@gmail.com>2014-02-14 20:03:57 +0100
commit6949f95f6e21980f36095490bf38fc8a172dbc0f (patch)
treeb3141f390acd0051396cda6a3da51c1f98384cca /system/libraries/Cache/drivers/Cache_memcached.php
parent68a02a01a086bbb1b8128ea2744439de84873d11 (diff)
parent81f036753272391360ba5b64e6dd93c4101a8733 (diff)
Merge remote-tracking branch 'upstream/develop' into develop
Conflicts: system/helpers/form_helper.php
Diffstat (limited to 'system/libraries/Cache/drivers/Cache_memcached.php')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php56
1 files changed, 45 insertions, 11 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index d2a3a489d..bed606afb 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -18,7 +18,7 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
- * @copyright Copyright (c) 2008 - 2013, EllisLab, Inc. (http://ellislab.com/)
+ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
* @link http://codeigniter.com
* @since Version 2.0
@@ -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;
@@ -110,6 +116,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
*
* @return bool false on failure/true on success