zend-framework – 清除Zend Cache的模式
发布时间:2020-12-13 16:26:24  所属栏目:PHP教程  来源:网络整理 
            导读:我开始使用Zend Cache(APC后端),并且在返回缓存值方面都很好,而不是每次都访问数据库.但是,继承人我的问题: $cache_key = 'getrebates_'.$operator_code;if(PP_Model_CacheService::exists($cache_key)) { $cached_values = PP_Model_CacheService::load($c
                
                
                
            | 
 我开始使用Zend Cache(APC后端),并且在返回缓存值方面都很好,而不是每次都访问数据库.但是,继承人我的问题: 
  
  
  $cache_key = 'getrebates_'.$operator_code;
if(PP_Model_CacheService::exists($cache_key)) {
    $cached_values = PP_Model_CacheService::load($cache_key);
} else {
   //hits the db    
   $cached_values = $this->getAll($operator_code);
   PP_Model_CacheService::save($cached_values,$cache_key);
}
return $cached_values;每个操作符都有自己的折扣,这些折扣因操作符而异,现在如果我更改数据库并需要清除所有操作符的折扣,我该怎么做? 我可以使用$Cache-> clean(),但这将清除其他缓存(不仅仅是每个运算符的rebate缓存).如果我循环遍历所有运算符: foreach($operator_codes AS $operator_code) {
   $cache_key = 'getrebates_'.$operator_code;
   $cache->delete($cache_key)
}这看起来像缓存的很多工作.有没有办法清除一部分缓存. //Something like: $section_key = 'getrebates'; $Cache[$section_key][$operator_code]; $Cache->clearSection($section_key); APC缓存是否有任何数组结构,还是基于缓存键/值? 
 您可以将标记应用于存储在缓存中的值.这样,您可以轻松删除具有特定标记的所有缓存条目. 
  
  
  $cache->save($huge_data,'myUniqueID',array('tagA','tagB'));
// clear all cache entries with tag tagA or tagC
$cache->clean(
  Zend_Cache::CLEANING_MODE_MATCHING_TAG,'tagC')
);有关Zend_Cache_Core:http://framework.zend.com/apidoc/1.11/的clean方法的详细信息,请参阅此页面:http://framework.zend.com/manual/en/zend.cache.theory.html和API (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! | 
