mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-07-03 23:46:49 +08:00
增加reset_setting命令
This commit is contained in:
parent
c426656d12
commit
85fcaea019
@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
namespace App\Console\Tasks;
|
namespace App\Console\Tasks;
|
||||||
|
|
||||||
|
use App\Caches\Setting as SettingCache;
|
||||||
use App\Library\Cache\Backend\Redis as RedisCache;
|
use App\Library\Cache\Backend\Redis as RedisCache;
|
||||||
|
use App\Models\Setting as SettingModel;
|
||||||
use Phalcon\Cli\Task;
|
use Phalcon\Cli\Task;
|
||||||
use Phalcon\Config;
|
use Phalcon\Config;
|
||||||
|
|
||||||
@ -11,11 +13,31 @@ class MaintainTask extends Task
|
|||||||
|
|
||||||
public function mainAction()
|
public function mainAction()
|
||||||
{
|
{
|
||||||
|
$this->resetSettingAction();
|
||||||
$this->resetAnnotationAction();
|
$this->resetAnnotationAction();
|
||||||
$this->resetMetadataAction();
|
$this->resetMetadataAction();
|
||||||
$this->resetVoltAction();
|
$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) {
|
if (count($keys) > 0) {
|
||||||
|
|
||||||
$keys = $this->handleKeys($keys);
|
$keys = $this->handlePhKeys($keys);
|
||||||
|
|
||||||
$redis->del(...$keys);
|
$redis->del(...$keys);
|
||||||
$redis->del($statsKey);
|
$redis->del($statsKey);
|
||||||
@ -69,7 +91,7 @@ class MaintainTask extends Task
|
|||||||
|
|
||||||
if (count($keys) > 0) {
|
if (count($keys) > 0) {
|
||||||
|
|
||||||
$keys = $this->handleKeys($keys);
|
$keys = $this->handlePhKeys($keys);
|
||||||
|
|
||||||
$redis->del(...$keys);
|
$redis->del(...$keys);
|
||||||
$redis->del($statsKey);
|
$redis->del($statsKey);
|
||||||
@ -118,7 +140,7 @@ class MaintainTask extends Task
|
|||||||
return $cache;
|
return $cache;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function handleKeys($keys)
|
protected function handlePhKeys($keys)
|
||||||
{
|
{
|
||||||
return array_map(function ($key) {
|
return array_map(function ($key) {
|
||||||
return "_PHCR{$key}";
|
return "_PHCR{$key}";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user