M3u8ClearServersCommand.php 993 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace App\Command\Init;
  3. use Carbon\Carbon;
  4. use Hyperf\Command\Command as HyperfCommand;
  5. use App\Repositories\Utils\M3u8CacheRepository;
  6. use Psr\Container\ContainerInterface;
  7. class M3u8ClearServersCommand extends HyperfCommand
  8. {
  9. /**
  10. * 执行的命令行
  11. *
  12. * @var string
  13. */
  14. protected $name = 'init:m3u8_clear_servers';
  15. /**
  16. * @var ContainerInterface
  17. */
  18. protected $container;
  19. public function __construct(ContainerInterface $container)
  20. {
  21. $this->container = $container;
  22. parent::__construct($this->name);
  23. }
  24. public function configure()
  25. {
  26. parent::configure();
  27. $this->setDescription('清理服务器组缓存.');
  28. $this->addUsage(" 无参数");
  29. }
  30. public function handle()
  31. {
  32. $nowDate = Carbon::now()->toDateTimeString();
  33. M3u8CacheRepository::clearServersCache();
  34. $this->comment(sprintf('[%s]清理服务器组缓存成功', $nowDate));
  35. }
  36. }