【问题标题】:Zend Framework Clearing CacheZend Framework 清除缓存
【发布时间】:2013-04-21 09:54:41
【问题描述】:

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

现在如何手动清除缓存?

【问题讨论】:

    标签: php zend-framework caching


    【解决方案1】:

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

    $cache->remove($CacheName);
    

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

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

    要删除缓存中的所有项目:

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

    【讨论】:

    • 没错。您能否给我们一个链接,指向您在其中找到这些信息的文档?
    • 它在文本的第一行 - 点击单词documentation
    猜你喜欢
    • 1970-01-01
    • 2012-03-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多