memcached tag 解决方案(转)
最近在网上看到有很多的开源项目,如memcached_tag、memcache_db 等等
而我也被这个memcached没有tag管理弄的很郁闷
如是乎就想了这个解决办法,主要也是借鉴了memcache的FAQ里面的内容,当然这里只是涉及简单的tag管理,复杂的我还在研发中~ 暂时没有想到更好的办法
/**
* tag分组
* @author 小黑米
* @access blog.phpexp.cn
* @version 1.0
* @copyright 2008-8-9
*
*/
class MyMemcached extends Memcache{
public function setToNamespace($namespace,$key,$data){
if(!($ns = $this->get($namespace))){
$ns = TIME;
$this->set($namespace,$ns);
}
$this->set("{$namespace}_{$key}",$data);
}
public function getFromNamespace($namespace,$key){
if(!($ns = $this->get($namespace))) return false;
return $this->get("{$namespace}_{$key}");
}
public function deleteNamespace($namespace){
$this->delete($namespace);
return true;
}
}
转:http://blog.phpexp.cn/themes/331
2条评论▼