From 85fcaea019759873fe11e3115167add272d2b8b9 Mon Sep 17 00:00:00 2001 From: xiaochong0302 Date: Mon, 7 Sep 2020 14:26:55 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0reset=5Fsetting=E5=91=BD?= =?UTF-8?q?=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Console/Tasks/MaintainTask.php | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/app/Console/Tasks/MaintainTask.php b/app/Console/Tasks/MaintainTask.php index 97ac7e1e..f8b1d1e6 100644 --- a/app/Console/Tasks/MaintainTask.php +++ b/app/Console/Tasks/MaintainTask.php @@ -2,7 +2,9 @@ namespace App\Console\Tasks; +use App\Caches\Setting as SettingCache; use App\Library\Cache\Backend\Redis as RedisCache; +use App\Models\Setting as SettingModel; use Phalcon\Cli\Task; use Phalcon\Config; @@ -11,11 +13,31 @@ class MaintainTask extends Task public function mainAction() { + $this->resetSettingAction(); $this->resetAnnotationAction(); $this->resetMetadataAction(); $this->resetVoltAction(); } + /** + * 重置设置 + * + * @command: php console.php maintain reset_setting + */ + public function resetSettingAction() + { + echo "start reset setting..." . PHP_EOL; + + $rows = SettingModel::query()->columns('section')->distinct(true)->execute(); + + foreach ($rows as $row) { + $cache = new SettingCache(); + $cache->rebuild($row->section); + } + + echo "end reset setting..." . PHP_EOL; + } + /** * 重置注解 * @@ -38,7 +60,7 @@ class MaintainTask extends Task if (count($keys) > 0) { - $keys = $this->handleKeys($keys); + $keys = $this->handlePhKeys($keys); $redis->del(...$keys); $redis->del($statsKey); @@ -69,7 +91,7 @@ class MaintainTask extends Task if (count($keys) > 0) { - $keys = $this->handleKeys($keys); + $keys = $this->handlePhKeys($keys); $redis->del(...$keys); $redis->del($statsKey); @@ -118,7 +140,7 @@ class MaintainTask extends Task return $cache; } - protected function handleKeys($keys) + protected function handlePhKeys($keys) { return array_map(function ($key) { return "_PHCR{$key}";