* [refac] close the cache to prevent new data from being written before clear cache.

This commit is contained in:
liugang
2024-12-09 09:21:27 +08:00
committed by 刘刚
parent f6147c8571
commit 4d2f17e88c
2 changed files with 9 additions and 3 deletions
+7 -1
View File
@@ -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);
}
}