* 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');
}
}
//Creates the Memcached object if needed
if(self::$instance===null){
global$Config;
self::$instance=newCacheMemcached();
self::$instance->memcached=newMemcached();
self::$instance->memcached->addServer(
$Config['cache']['server'],
$Config['cache']['port']
);
}
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