summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache/drivers/Cache_memcached.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-03-26 14:34:39 +0200
committerAndrey Andreev <narf@bofh.bg>2012-03-26 14:34:39 +0200
commitb24b033a9c285c98802fbd7bf16d486e355e2f97 (patch)
tree3a61d3230bb67f31f4d57984f7b64a310d635751 /system/libraries/Cache/drivers/Cache_memcached.php
parent03c644d7224847402058cde0fa3fbb4e810bfdf2 (diff)
Switch private methods and properties to protected and cleanup the Cache library and drivers
Diffstat (limited to 'system/libraries/Cache/drivers/Cache_memcached.php')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php57
1 files changed, 25 insertions, 32 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b8f2d7e4c..1028c8fd5 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;
}
@@ -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