From 4792c1dad18a35f82f6f3ea8b4a2531933a590b7 Mon Sep 17 00:00:00 2001 From: liugang Date: Fri, 6 Dec 2024 11:12:26 +0800 Subject: [PATCH] * [bug#57812,1h] fix can't close cache. --- module/cache/control.php | 4 ++-- module/cache/model.php | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) 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 d1315b7e93..3b6e9001f6 100644 --- a/module/cache/model.php +++ b/module/cache/model.php @@ -18,12 +18,14 @@ class cacheModel extends model * @access public * @return void */ - public function clear() + public function clear($needStart = true) { /* 多应用共享时采用遍历删除的方式,所以需要先关闭缓存,清空之后再打开。When multiple applications share the cache, the cache needs to be closed first, cleared, and then opened. */ - $needStop = $this->config->cache->scope == 'shared'; + $needStop = $this->config->cache->enable && $this->config->cache->scope == 'shared'; if($needStop) $this->loadModel('setting')->setItem('system.common.cache.enable', 0); + $this->mao->clearCache(); - if($needStop) $this->setting->setItem('system.common.cache.enable', 1); + + if($needStop && $needStart) $this->loadModel('setting')->setItem('system.common.cache.enable', 1); } }