new-admin-api/app/command/clearCache.php

60 lines
1.4 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare (strict_types=1);
namespace app\command;
use Swoole\Coroutine\MySQL\Exception;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use think\console\Output;
use think\event\RouteLoaded;
use think\facade\Cache;
use think\facade\Route;
use app\common\repositories\system\auth\MenuRepository;
class clearCache extends Command
{
protected function configure()
{
// 指令配置
$this->setName('clearCache')
->addArgument('cacheType',Argument::OPTIONAL, 'php think menu [1] / [2]')
->setDescription('清楚缓存php think clearCache 1');
}
/**
* TODO
* @param Input $input
* @param Output $output
* @return int|void|null
* @author Qinii
* @day 4/24/22
*/
protected function execute(Input $input, Output $output)
{
$type = $input->getArgument('cacheType');
$tag = ['sys_login_freeze','mer_login_freeze'];
$msg = '';
switch ($type) {
case 0:
$msg = '平台登录限制';
$tag = 'sys_login_freeze';
break;
case 1:
$msg = '商户登录限制';
$tag = 'mer_login_freeze';
break;
}
Cache::tag($tag)->clear();
$output->writeln('清楚缓存'.$msg);
}
}