123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Bear
- * Date: 2019/1/7
- * Time: 下午3:49
- */
- namespace app\admin\command;
- use app\common\library\Redis;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\Output;
- use think\Request;
- class ClearCampaignRedis extends Command
- {
- public function Configure()
- {
- $this->setName('ClearCampaignRedis')
- ->addArgument('pre', Argument::OPTIONAL, 'redis前缀', null)
- ->addArgument('key', Argument::OPTIONAL, '要清除得key', null)
- ->setDescription('clear ClearCampaignRedis redis');
- }
- /**
- * @param Input $input
- * @param Output $output
- * @return int|null|void
- * @throws \Exception
- * @throws \think\Exception
- */
- public function execute(Input $input, Output $output)
- {
- Request::instance()->module('admin');
- $pre = $input->getArgument('pre');
- $key = $input->getArgument('key');
- $redisArr = [
- 'MR:','MRLATEST','MC:','UCR:','UMCS:','UMO:','CMK:','UMF:','MCL:','LK:','MCS:','MC_USERLIST','SAB:','SAU:','SAUL:',
- ];
- if (!in_array($pre, $redisArr) || strstr($pre,'*') !== false || strstr($key,'*') !== false ){
- echo '不能清除此key';exit;
- }
- $res = Redis::instance()->del($key);
- dump($res);
- }
- }
|