VideoHomeCacheCommand.php 1013 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Command;
  4. use App\Model\VideoModel;
  5. use App\Repositories\Service\CommonService;
  6. use App\Repositories\Utils\M3u8CacheRepository;
  7. use App\Repositories\VideoRepository;
  8. use Hyperf\Command\Command as HyperfCommand;
  9. use Hyperf\Command\Annotation\Command;
  10. use Modules\Api\Services\VideoService;
  11. use Psr\SimpleCache\CacheInterface;
  12. /**
  13. * @Command
  14. */
  15. class VideoHomeCacheCommand extends HyperfCommand
  16. {
  17. public function __construct()
  18. {
  19. parent::__construct('video:home');
  20. }
  21. public function configure()
  22. {
  23. parent::configure();
  24. $this->setDescription('首页视频流');
  25. }
  26. public function handle()
  27. {
  28. $this->info('开始缓存视频首页');
  29. $videoRepo = make(VideoRepository::class);
  30. $videoRepo->initHomeVideoGroups();
  31. $videoRepo->clearAllLastestPagesCache();
  32. logger('VideoHomeCacheCommand-缓存视频首页');
  33. $this->info("首页推荐视频缓存成功.");
  34. }
  35. }