* Gets the cache instance, initializing it if needed
*
* @return Cache the cache instance, or null if nothing is cached
*/
staticfunctionload(){
//Checks extension is okay
if(!extension_loaded('memcached')){
if(extension_loaded('memcache')){
message_die(GENERAL_ERROR,"Can't initialize $engine cache engine.<br />PHP extension memcached not loaded.<br /><strong>!!! This class uses the Memcached extension AND NOT the Memcache extension (this one is loaded) !!!</strong>",'Cache');
}else{
message_die(GENERAL_ERROR,"Can't initialize $engine cache engine.<br />PHP extension memcached not loaded.",'Cache');
message_die(GENERAL_ERROR,"Can't initialize $engine cache engine.<br />PHP extension memcached were compiled without SASL support.<br /> SASL authentication support is disabled by default. To enable it, recompile the PECL memcached extension using --enable-memcached-sasl switch. This requires that libsasl2 has been installed and that libmemcached has been built with SASL support enabled.",'Cache');
}
self::$instance->memcached->setSaslAuthData(
$Config['cache']['username'],
$Config['cache']['password']
);
}
$stats=self::$instance->memcached->getStats();
}
returnself::$instance;
}
/**
* Gets the specified key's data
*
* @param string $key the key to fetch
* @return mixed the data at the specified key
*/
functionget($key){
return$this->memcached->get($key);
}
/**
* Sets the specified data at the specified key
*
* @param string $key the key where to store the specified data