summaryrefslogtreecommitdiffstats
path: root/system/libraries/Cache/drivers/Cache_memcached.php
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-08-21 19:29:43 +0200
committerGreg Aker <greg@gregaker.net>2011-08-21 19:29:43 +0200
commit151b7a9abed49e76232ad195cc2c010bfc82f22a (patch)
treebb186a876bd504a3f398d81c1bd58b18cc821436 /system/libraries/Cache/drivers/Cache_memcached.php
parent3932f3de79dad126771dc75566f73a098d276fdd (diff)
Cleaning up some tabs/spaces issues. Also stripped trailing white space from the file.
Diffstat (limited to 'system/libraries/Cache/drivers/Cache_memcached.php')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php103
1 files changed, 51 insertions, 52 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index b9593b734..ae9d6cd96 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -10,19 +10,19 @@
* @license http://codeigniter.com/user_guide/license.html
* @link http://codeigniter.com
* @since Version 2.0
- * @filesource
+ * @filesource
*/
// ------------------------------------------------------------------------
/**
- * CodeIgniter Memcached Caching Class
+ * CodeIgniter Memcached Caching Class
*
* @package CodeIgniter
* @subpackage Libraries
* @category Core
* @author ExpressionEngine Dev Team
- * @link
+ * @link
*/
class CI_Cache_memcached extends CI_Driver {
@@ -37,18 +37,18 @@ class CI_Cache_memcached extends CI_Driver {
)
);
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Fetch from cache
*
* @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;
}
@@ -68,7 +68,7 @@ class CI_Cache_memcached extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
/**
* Delete from Cache
*
@@ -81,7 +81,7 @@ class CI_Cache_memcached extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
/**
* Clean the Cache
*
@@ -106,7 +106,7 @@ class CI_Cache_memcached extends CI_Driver {
}
// ------------------------------------------------------------------------
-
+
/**
* Get Cache Metadata
*
@@ -140,6 +140,7 @@ class CI_Cache_memcached extends CI_Driver {
{
// Try to load memcached server info from the config file.
$CI =& get_instance();
+
if ($CI->config->load('memcached', TRUE, TRUE))
{
if (is_array($CI->config->config['memcached']))
@@ -149,24 +150,24 @@ class CI_Cache_memcached extends CI_Driver {
foreach ($CI->config->config['memcached'] as $name => $conf)
{
$this->_memcache_conf[$name] = $conf;
- }
- }
+ }
+ }
+ }
+
+ if (class_exists('Memcached'))
+ {
+ $this->_memcached = new Memcached();
+ }
+ else if (class_exists('Memcache'))
+ {
+ $this->_memcached = new Memcache();
}
+ else
+ {
+ log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
- if (class_exists('Memcached'))
- {
- $this->_memcached = new Memcached();
- }
- else if (class_exists('Memcache'))
- {
- $this->_memcached = new Memcache();
- }
- else
- {
- log_message('error', 'Failed to create object for Memcached Cache; extension not loaded?');
-
- return FALSE;
- }
+ return FALSE;
+ }
foreach ($this->_memcache_conf as $name => $cache_server)
{
@@ -174,43 +175,42 @@ class CI_Cache_memcached extends CI_Driver {
{
$cache_server['hostname'] = $this->_default_options['default_host'];
}
-
+
if ( ! array_key_exists('port', $cache_server))
{
$cache_server['port'] = $this->_default_options['default_port'];
}
-
+
if ( ! array_key_exists('weight', $cache_server))
{
$cache_server['weight'] = $this->_default_options['default_weight'];
}
-
- if (get_class($this->_memcached) == 'Memcache')
- {
- // Third parameter is persistance and defaults to TRUE.
- $this->_memcached->addServer(
- $cache_server['hostname'],
- $cache_server['port'],
- TRUE,
- $cache_server['weight']
- );
- }
- else
- {
- $this->_memcached->addServer(
- $cache_server['hostname'],
- $cache_server['port'],
- $cache_server['weight']
- );
- }
+
+ if (get_class($this->_memcached) == 'Memcache')
+ {
+ // Third parameter is persistance and defaults to TRUE.
+ $this->_memcached->addServer(
+ $cache_server['hostname'],
+ $cache_server['port'],
+ TRUE,
+ $cache_server['weight']
+ );
+ }
+ else
+ {
+ $this->_memcached->addServer(
+ $cache_server['hostname'],
+ $cache_server['port'],
+ $cache_server['weight']
+ );
+ }
}
- return TRUE;
+ return TRUE;
}
// ------------------------------------------------------------------------
-
/**
* Is supported
*
@@ -219,14 +219,13 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function is_supported()
{
- if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
+ 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();
}