cacher = Cache::getInstance('cacheredis'); } /** * 清理缓存 */ public function clearOp() { if (!chksubmit()) { Tpl::showpage('cache.clear'); return; } $lang = Language::getLangContent(); // 清理所有缓存 if ($_POST['cls_full'] == 1) { foreach ($this->cacheItems as $i) { dkcache($i); } //area dkcache('area_toplevelareas'); // 省级别缓存处理 dkcache('area_cityprovince'); // 市级别缓存处理 // 表主键 Model::dropTablePkArrayCache(); // 商品分类 dkcache('gc_class'); dkcache('all_categories'); dkcache('goods_class_seo'); dkcache('class_tag'); // 广告 Model('adv')->makeApAllCache(); // 首页 Model('web_config')->getWebHtml('index', 1); delCacheFile('index'); // 删除商品相关数据 $this->del_keys('goods*'); // 删除手机红包相关缓存 $this->del_keys('bonus*'); //删除手机专题活动相关缓存 $this->del_keys('specials*'); //删除手机发现页相关缓存 $this->del_keys('discovery*'); } else { $todo = (array) $_POST['cache']; foreach ($this->cacheItems as $i) { if (in_array($i, $todo)) { dkcache($i); } } // 表主键 if (in_array('table', $todo)) { Model::dropTablePkArrayCache(); } // 商品分类 if (in_array('goodsclass', $todo)) { dkcache('gc_class'); dkcache('all_categories'); dkcache('goods_class_seo'); dkcache('class_tag'); } // 广告 if (in_array('adv', $todo)) { Model('adv')->makeApAllCache(); } // 首页 if (in_array('index', $todo)) { Model('web_config')->getWebHtml('index', 1); delCacheFile('index'); } // 省市区地址 if (in_array('area', $todo)) { dkcache('area'); dkcache('area_toplevelareas'); // 省级别缓存处理 dkcache('area_cityprovince'); // 市级别缓存处理 } // 删除商品相关数据 if (in_array('goods',$todo)) { $this->del_keys('goods*'); } // 删除手机红包相关缓存 if (in_array('bonus',$todo)) { $this->del_keys('bonus*'); } // 删除手机专题活动相关缓存 if (in_array('specials',$todo)) { $this->del_keys('specials*'); } // 删除手机发现页相关缓存 if (in_array('discovery',$todo)) { $this->del_keys('discovery*'); } } $this->log(L('cache_cls_operate')); showMessage($lang['cache_cls_ok']); } /** * 删除通配的keys * @param $key * @return bool */ protected function del_keys($key) { $keys = $this->cacher->keys($key); if(!empty($keys) && is_array($keys)){ foreach($keys as $key) { $this->cacher->del($key); } } return true; } }