<?php /** * Created by PhpStorm. * User: Administrator * Date: 2019/8/13 * Time: 10:59 */ namespace App\Console\Commands; use App\Models\PostComment; use Illuminate\Console\Command; use Illuminate\Support\Facades\Redis; class DelPostNewReply extends Command { /** * The name and signature of the console command. * * @var string */ protected $signature = 'post:del_post_new_reply'; /** * The console command description. * * @var string */ protected $description = '删除内容新回复缓存'; /** * Create a new command instance. * * @return void */ public function __construct(PostComment $postComment) { parent::__construct(); $this->postComment = $postComment; } /** * Execute the console command. * * @return mixed */ public function handle() { $this->line("开始删除内容新回复缓存"); $max = $this->postComment->max('id'); $bar = $this->output->createProgressBar($max); for($i=1;$i<=$max;$i++){ Redis::DEL('post_new_reply_'.$i); $bar->advance(); usleep(10000); } $bar->finish(); $this->line("\n删除内容新回复缓存结束"); } }