gpt4 book ai didi

php - Zend Framework 清除缓存

转载 作者:可可西里 更新时间:2023-11-01 13:50:36 25 4
gpt4 key购买 nike

我正在使用这段代码在 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

现在如何手动清除缓存?

最佳答案

根据documentation一次调用 remove() 方法就足够了,即删除一个特定的缓存项:

$cache->remove($CacheName);

如果要清理过时的缓存项,则调用clean()方法:

$cache->clean(Zend_Cache::CLEANING_MODE_OLD);

删除缓存中的所有项目:

$cache->clean(Zend_Cache::CLEANING_MODE_ALL);

关于php - Zend Framework 清除缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16129925/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com