php Zend 框架清除缓存
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16129925/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Zend Framework Clearing Cache
提问by Zero Cool
I'm using this code to cache an array in zend framework :
我正在使用此代码在 zend 框架中缓存数组:
$frontendOptions = array(
'lifetime' => 24 * 3600 * 7, // cache lifetime of 7 day
'automatic_serialization' => true
);
$backendOptions = array(
// Directory where to put the cache files
'cache_dir' => APPLICATION_PATH .'/../tmp'
);
// getting a Zend_Cache_Core object
$cache = Zend_Cache::factory('Core',
'File',
$frontendOptions,
$backendOptions);
$CacheName = ('VOUCHER_MANAGEMENT');
$CacheResult = $cache->load($CacheName);
if($CacheResult === false)
//make cache
else
//use cache
Now how can I clear the cache manually?
现在如何手动清除缓存?
回答by Havelock
According to the documentationa single call of the remove()
method would suffice, i.e. to remove a specific cache item:
根据文档,该remove()
方法的一次调用就足够了,即删除特定的缓存项:
$cache->remove($CacheName);
If you want to clean the outdated cache items, then call the clean()
method:
如果要清理过时的缓存项,则调用该clean()
方法:
$cache->clean(Zend_Cache::CLEANING_MODE_OLD);
To remove all items in the cache:
要删除缓存中的所有项目:
$cache->clean(Zend_Cache::CLEANING_MODE_ALL);