diff --git a/module/cache/control.php b/module/cache/control.php index c6e4aec6dd..ff76887371 100644 --- a/module/cache/control.php +++ b/module/cache/control.php @@ -74,7 +74,7 @@ class cache extends control $this->loadModel('setting')->setItems('system.common.cache', $cache); $this->setting->setItems('system.common.redis', $redis); - $this->cache->clear(); + $this->cache->clear($cache->enable); return $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'load' => true)); } @@ -99,7 +99,7 @@ class cache extends control */ public function flush() { - $this->cache->clear(); + $this->cache->clear($this->config->cache->enable); return $this->send(array('result' => 'success', 'message' => $this->lang->cache->clearSuccess, 'load' => true)); } } diff --git a/module/cache/model.php b/module/cache/model.php index 7a74b2eb92..60f5694978 100644 --- a/module/cache/model.php +++ b/module/cache/model.php @@ -18,8 +18,14 @@ class cacheModel extends model * @access public * @return void */ - public function clear() + public function clear($needStart = true) { + /* 先关闭缓存防止清空缓存过程中有新的数据写入。Close the cache first to prevent new data from being written during the cache clearing process. */ + $needStop = $this->config->cache->enable; + if($needStop) $this->loadModel('setting')->setItem('system.common.cache.enable', 0); + $this->mao->clearCache(); + + if($needStop && $needStart) $this->loadModel('setting')->setItem('system.common.cache.enable', 1); } }