一个强大的PHP缓存类(3)
}
/*echo '<br />--returnning data for key:'.$key;
var_dump($data);*/
return $data;
}
//delete key from cache
public function delete($key){
switch($this->cache_type){
case 'eaccelerator':
eaccelerator_rm($key);
break;
case 'apc':
apc_delete($key);
break;
case 'xcache':
xcache_unset($key);
break;
case 'memcache':
$this->cache_external->delete($key);
break;
case 'filecache':
$this->cache_external->delete($key);
break;
}
}
// Overloading for the Application variables and automatically cached
public function __set($name, $value) {
$this->put($name, $value, $this->cache_expire);
}
public function __get($name) {
return $this->get($name);
}
public function __isset($key) {//echo "Is '$name' set?\n"
if ($this->get($key) !== false) return true;
else return false;
}
public function __unset($name) {//echo "Unsetting '$name'\n";
$this->delete($name);
}
//end overloads
public function getCacheType(){
return $this->$this->cache_type;
}
//sets the cache if its installed if not triggers error
public function setCacheType($type){
$this->cache_type=strtolower($type);
switch($this->cache_type){
case 'eaccelerator':
if (function_exists('eaccelerator_get')) $this->cache_type = 'eaccelerator';
else $this->cacheError('eaccelerator not found');
break;
case 'apc':
if (function_exists('apc_fetch')) $this->cache_type = 'apc' ;
顶(0)
踩(0)
- 最新评论
