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); } }