DelPostNewReply.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2019/8/13
  6. * Time: 10:59
  7. */
  8. namespace App\Console\Commands;
  9. use App\Models\PostComment;
  10. use Illuminate\Console\Command;
  11. use Illuminate\Support\Facades\Redis;
  12. class DelPostNewReply extends Command
  13. {
  14. /**
  15. * The name and signature of the console command.
  16. *
  17. * @var string
  18. */
  19. protected $signature = 'post:del_post_new_reply';
  20. /**
  21. * The console command description.
  22. *
  23. * @var string
  24. */
  25. protected $description = '删除内容新回复缓存';
  26. /**
  27. * Create a new command instance.
  28. *
  29. * @return void
  30. */
  31. public function __construct(PostComment $postComment)
  32. {
  33. parent::__construct();
  34. $this->postComment = $postComment;
  35. }
  36. /**
  37. * Execute the console command.
  38. *
  39. * @return mixed
  40. */
  41. public function handle()
  42. {
  43. $this->line("开始删除内容新回复缓存");
  44. $max = $this->postComment->max('id');
  45. $bar = $this->output->createProgressBar($max);
  46. for($i=1;$i<=$max;$i++){
  47. Redis::DEL('post_new_reply_'.$i);
  48. $bar->advance();
  49. usleep(10000);
  50. }
  51. $bar->finish();
  52. $this->line("\n删除内容新回复缓存结束");
  53. }
  54. }