summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache/drivers/Cache_memcached.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-04-03 19:21:39 +0200
committerAndrey Andreev <narf@bofh.bg>2012-04-03 19:21:39 +0200
commit320d37c090cbc1497d3951f64da1c16e86bae609 (patch)
tree51e1bf36e4d63e233e0b9b550420805d65548945 /system/libraries/Cache/drivers/Cache_memcached.php
parent31cf46eaec3b4613d5b46f9caed8bdd346b581cc (diff)
parent78f55772adb86b48d0d50572545c24c18f528ff9 (diff)
Merge upstream branch
Diffstat (limited to 'system/libraries/Cache/drivers/Cache_memcached.php')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php63
1 files changed, 28 insertions, 35 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b8f2d7e4c..4cd5f3d6f 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -25,8 +25,6 @@
* @filesource
*/
-// ------------------------------------------------------------------------
-
/**
* CodeIgniter Memcached Caching Class
*
@@ -36,12 +34,11 @@
* @author EllisLab Dev Team
* @link
*/
-
class CI_Cache_memcached extends CI_Driver {
- private $_memcached; // Holds the memcached object
+ protected $_memcached; // Holds the memcached object
- protected $_memcache_conf = array(
+ protected $_memcache_conf = array(
'default' => array(
'default_host' => '127.0.0.1',
'default_port' => 11211,
@@ -49,19 +46,17 @@ class CI_Cache_memcached extends CI_Driver {
)
);
- // ------------------------------------------------------------------------
-
/**
* Fetch from cache
*
- * @param mixed unique key id
- * @return mixed data on success/false on failure
+ * @param mixed unique key 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] : FALSE;
}
// ------------------------------------------------------------------------
@@ -69,18 +64,18 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Save
*
- * @param string unique identifier
- * @param mixed data being cached
- * @param int time to live
- * @return boolean true on success, false on failure
+ * @param string unique identifier
+ * @param mixed data being cached
+ * @param int time to live
+ * @return bool true on success, false on failure
*/
public function save($id, $data, $ttl = 60)
{
- if (get_class($this->_memcached) == 'Memcached')
+ if (get_class($this->_memcached) === 'Memcached')
{
return $this->_memcached->set($id, array($data, time(), $ttl), $ttl);
}
- else if (get_class($this->_memcached) == 'Memcache')
+ elseif (get_class($this->_memcached) === 'Memcache')
{
return $this->_memcached->set($id, array($data, time(), $ttl), 0, $ttl);
}
@@ -93,8 +88,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Delete from Cache
*
- * @param mixed key to be deleted.
- * @return boolean true on success, false on failure
+ * @param mixed key to be deleted.
+ * @return bool true on success, false on failure
*/
public function delete($id)
{
@@ -106,7 +101,7 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Clean the Cache
*
- * @return boolean false on failure/true on success
+ * @return bool false on failure/true on success
*/
public function clean()
{
@@ -118,10 +113,9 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Cache Info
*
- * @param null type not supported in memcached
- * @return mixed array on success, false on failure
+ * @return mixed array on success, false on failure
*/
- public function cache_info($type = NULL)
+ public function cache_info()
{
return $this->_memcached->getStats();
}
@@ -131,8 +125,8 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Get Cache Metadata
*
- * @param mixed key to get cache metadata on
- * @return mixed FALSE on failure, array on success.
+ * @param mixed key to get cache metadata on
+ * @return mixed FALSE on failure, array on success.
*/
public function get_metadata($id)
{
@@ -156,8 +150,10 @@ class CI_Cache_memcached extends CI_Driver {
/**
* Setup memcached.
+ *
+ * @return bool
*/
- private function _setup_memcached()
+ protected function _setup_memcached()
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
@@ -179,14 +175,13 @@ class CI_Cache_memcached extends CI_Driver {
{
$this->_memcached = new Memcached();
}
- else if (class_exists('Memcache'))
+ elseif (class_exists('Memcache'))
{
$this->_memcached = new Memcache();
}
else
{
log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
-
return FALSE;
}
@@ -194,17 +189,17 @@ class CI_Cache_memcached extends CI_Driver {
{
if ( ! array_key_exists('hostname', $cache_server))
{
- $cache_server['hostname'] = $this->_default_options['default_host'];
+ $cache_server['hostname'] = $this->_memcache_conf['default']['default_host'];
}
if ( ! array_key_exists('port', $cache_server))
{
- $cache_server['port'] = $this->_default_options['default_port'];
+ $cache_server['port'] = $this->_memcache_conf['default']['default_port'];
}
if ( ! array_key_exists('weight', $cache_server))
{
- $cache_server['weight'] = $this->_default_options['default_weight'];
+ $cache_server['weight'] = $this->_memcache_conf['default']['default_weight'];
}
if (get_class($this->_memcached) == 'Memcache')
@@ -237,23 +232,21 @@ class CI_Cache_memcached extends CI_Driver {
*
* Returns FALSE if memcached is not supported on the system.
* If it is, we setup the memcached object & return TRUE
+ *
+ * @return bool
*/
public function is_supported()
{
if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
-
return FALSE;
}
return $this->_setup_memcached();
}
- // ------------------------------------------------------------------------
-
}
-// End Class
/* End of file Cache_memcached.php */
-/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */
+/* Location: ./system/libraries/Cache/drivers/Cache_memcached.php */ \ No newline at end of file