cacher = Cache::getInstance('cacheredis'); $this->mPublisher = new message\publisher(); } /** * 清理缓存 */ 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'); // 市级别缓存处理 dcache('area','mb_'); // 表主键 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->mPublisher->modify_goods(); // 删除手机红包相关缓存 $this->del_keys('bonus*'); //删除手机专题活动相关缓存 $this->del_keys('mb_special*'); $this->mPublisher->modify_index_special(); dkcache('web_code_123'); $this->mPublisher->modify_index_tabs(); //删除手机发现页相关缓存 $this->del_keys('discovery*'); //删除手机促销相关数据 $this->mPublisher->modify_seracher_init(); $this->del_keys('mb_brand'); dcache('brandex','mb_'); $this->mPublisher->modify_index_brands(); $this->mPublisher->modify_activity(); $this->mPublisher->modify_activity_optional_goods(); $this->mPublisher->modify_activity_goods_sampler(); $this->mPublisher->modify_activity_bargain_goods(); $this->mPublisher->modify_refill_channel(); } 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'); // 市级别缓存处理 dcache('area','mb_'); } // 删除商品相关数据 if (in_array('goods',$todo)) { $this->del_keys('goods*'); $this->mPublisher->modify_goods(); } // 删除手机红包相关缓存 if (in_array('bonus',$todo)) { $this->del_keys('bonus*'); } // 删除手机专题活动相关缓存 if (in_array('specials',$todo)) { $this->del_keys('mb_special*'); $this->mPublisher->modify_index_special(); dkcache('web_code_123'); $this->mPublisher->modify_index_tabs(); } // 删除手机发现页相关缓存 if (in_array('discovery',$todo)) { $this->del_keys('discovery*'); } // 删除手机促销相关数据 if (in_array('salelist',$todo)) { dcache('brand','mb_'); dcache('brandex','mb_'); $this->mPublisher->modify_index_brands(); } if (in_array('searcher_goods',$todo)) { //搜索引擎重新加载数据 $this->mPublisher->modify_seracher_init(); } if(in_array('pay_fcode',$todo)) { $this->mPublisher->modify_index_payfcode(); $this->mPublisher->modify_index_presentfcode(); } if(in_array('optional_goods',$todo)) { $this->mPublisher->modify_activity_optional_goods(); } if(in_array('goods_sampler',$todo)) { $this->mPublisher->modify_activity_goods_sampler(); } if(in_array('bargain_goods',$todo)) { $this->mPublisher->modify_activity_bargain_goods(); } if(in_array('refill_channel',$todo)) { $this->mPublisher->modify_refill_channel(); } } $this->log(L('cache_cls_operate')); showMessage($lang['cache_cls_ok']); } private function inc_version($name) { $version = rkcache($name); if(empty($version)) { $version = 1; } else { $version = intval($version) + 1; } wkcache($name, $version); } /** * 删除通配的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; } }