summaryrefslogtreecommitdiffstats
path: root/system/libraries
diff options
context:
space:
mode:
authorGreg Aker <greg@gregaker.net>2011-08-21 19:03:08 +0200
committerGreg Aker <greg@gregaker.net>2011-08-21 19:03:08 +0200
commit3932f3de79dad126771dc75566f73a098d276fdd (patch)
tree3cceabfcc57367d7131e41f53ef7ea288b4d11ef /system/libraries
parent27a883c946ee524bb7930edfcfc6e8c153119929 (diff)
parent51e4bcab4d123c1ba65031dd5362c98d8c510493 (diff)
Merge branch 'issue45' of https://github.com/johnbellone/CodeIgniter into johnbellone-issue45
Diffstat (limited to 'system/libraries')
-rw-r--r--system/libraries/Cache/drivers/Cache_memcached.php48
1 files changed, 39 insertions, 9 deletions
diff --git a/system/libraries/Cache/drivers/Cache_memcached.php b/system/libraries/Cache/drivers/Cache_memcached.php
index ec2fd216a..b9593b734 100644
--- a/system/libraries/Cache/drivers/Cache_memcached.php
+++ b/system/libraries/Cache/drivers/Cache_memcached.php
@@ -152,8 +152,21 @@ class CI_Cache_memcached extends CI_Driver {
}
}
}
-
- $this->_memcached = new Memcached();
+
+ 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;
+ }
foreach ($this->_memcache_conf as $name => $cache_server)
{
@@ -172,10 +185,27 @@ class CI_Cache_memcached extends CI_Driver {
$cache_server['weight'] = $this->_default_options['default_weight'];
}
- $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;
}
// ------------------------------------------------------------------------
@@ -189,15 +219,15 @@ class CI_Cache_memcached extends CI_Driver {
*/
public function is_supported()
{
- if ( ! extension_loaded('memcached'))
+ if ( ! extension_loaded('memcached') && ! extension_loaded('memcache'))
{
log_message('error', 'The Memcached Extension must be loaded to use Memcached Cache.');
return FALSE;
}
-
- $this->_setup_memcached();
- return TRUE;
+
+
+ return $this->_setup_memcached();
}
// ------------------------------------------------------------------------