cache.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <?php
  2. /**
  3. * 清理缓存
  4. ***/
  5. defined('InShopNC') or exit('Access Invalid!');
  6. class cacheControl extends SystemControl
  7. {
  8. protected $cacheItems = array(
  9. 'setting', // 基本缓存
  10. 'seo', // SEO缓存
  11. 'groupbuy_price', // 抢购价格区间
  12. 'nav', // 底部导航缓存
  13. 'express', // 快递公司
  14. 'store_class', // 店铺分类
  15. 'store_grade', // 店铺等级
  16. 'store_msg_tpl', // 店铺消息
  17. 'member_msg_tpl', // 用户消息
  18. 'consult_type', // 咨询类型
  19. 'circle_level', // 圈子成员等级
  20. 'area', // 省市区地址
  21. 'home_goods', // 手机首页商品缓存
  22. 'bonus', // 手机红包相关缓存
  23. 'specials', // 手机专题活动相关缓存
  24. 'discovery', // 手机发现页相关缓存
  25. );
  26. public function __construct()
  27. {
  28. parent::__construct();
  29. Language::read('cache');
  30. }
  31. /**
  32. * 清理缓存
  33. */
  34. public function clearOp()
  35. {
  36. if (!chksubmit()) {
  37. Tpl::showpage('cache.clear');
  38. return;
  39. }
  40. $lang = Language::getLangContent();
  41. // 清理所有缓存
  42. if ($_POST['cls_full'] == 1) {
  43. foreach ($this->cacheItems as $i) {
  44. dkcache($i);
  45. }
  46. //area
  47. dkcache('area_toplevelareas'); // 省级别缓存处理
  48. dkcache('area_cityprovince'); // 市级别缓存处理
  49. // 表主键
  50. Model::dropTablePkArrayCache();
  51. // 商品分类
  52. dkcache('gc_class');
  53. dkcache('all_categories');
  54. dkcache('goods_class_seo');
  55. dkcache('class_tag');
  56. // 广告
  57. Model('adv')->makeApAllCache();
  58. // 首页
  59. Model('web_config')->getWebHtml('index', 1);
  60. delCacheFile('index');
  61. // 删除商品相关数据
  62. $cacher = Cache::getInstance('cacheredis');
  63. $keys = $cacher->keys('goods*');
  64. if(!empty($keys) && is_array($keys)){
  65. foreach($keys as $key) {
  66. $cacher->del($key);
  67. }
  68. }
  69. } else {
  70. $todo = (array) $_POST['cache'];
  71. foreach ($this->cacheItems as $i) {
  72. if (in_array($i, $todo)) {
  73. dkcache($i);
  74. }
  75. }
  76. // 表主键
  77. if (in_array('table', $todo)) {
  78. Model::dropTablePkArrayCache();
  79. }
  80. // 商品分类
  81. if (in_array('goodsclass', $todo)) {
  82. dkcache('gc_class');
  83. dkcache('all_categories');
  84. dkcache('goods_class_seo');
  85. dkcache('class_tag');
  86. }
  87. // 广告
  88. if (in_array('adv', $todo)) {
  89. Model('adv')->makeApAllCache();
  90. }
  91. // 首页
  92. if (in_array('index', $todo)) {
  93. Model('web_config')->getWebHtml('index', 1);
  94. delCacheFile('index');
  95. }
  96. // 省市区地址
  97. if (in_array('area', $todo)) {
  98. dkcache('area');
  99. dkcache('area_toplevelareas'); // 省级别缓存处理
  100. dkcache('area_cityprovince'); // 市级别缓存处理
  101. }
  102. // 删除商品相关数据
  103. if (in_array('goods',$todo)) {
  104. $cacher = Cache::getInstance('cacheredis');
  105. $keys = $cacher->keys('goods*');
  106. if(!empty($keys) && is_array($keys)){
  107. foreach($keys as $key) {
  108. $cacher->del($key);
  109. }
  110. }
  111. }
  112. }
  113. $this->log(L('cache_cls_operate'));
  114. showMessage($lang['cache_cls_ok']);
  115. }
  116. }