我们在Web项目中使用Memcached和Zend Framework。现在,我们需要使用Zend_Cache API中指定的标记有选择地清理缓存。
不幸的是,memcached doesn't support tags。
我找到了这些解决方法:
提前致谢
答案 0 :(得分:2)
你是对的。 Memcache不支持标签。
您可以使用另一个键值来实现memcache的标记。
EX:
$ this-> objCache-> save($ arrResults,$ strKey,array($ strMyTag),$ intCacheTime)//注意:数组($ strMyTag)不适用于Memcache
MemcacheTag :: setTag($ strKey,$ strMyTag)//我们的工作
关于setTag方法& MemcacheTag:
function setTag($ strKey,$ strTag){
$arrKey = $cacheOjb->get($strTag);
$arrKey[]= $strKey;
}
function deleteCacheWithTag($ strTag){
$arrKey = $cacheOjb->get($strTag);
foreach ($arrKey as $strKey){
$objCache->delete($strKey);
}
}
这项工作非常简单,适用于我的项目。
*注意:这些代码需要一些修改,抱歉匆忙发布