FarmHouseJsonConfig.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. namespace App\Module\Game\DCache;
  3. use App\Module\Farm\Commands\GenerateFarmHouseConfigJson;
  4. use App\Module\LCache\DQueueJob;
  5. /**
  6. * 农场房屋配置表缓存
  7. */
  8. class FarmHouseJsonConfig extends DQueueJob
  9. {
  10. /**
  11. * 获取新数据
  12. *
  13. * @param array $parameter 参数
  14. * @return mixed
  15. */
  16. static public function getNewData(array $parameter = [])
  17. {
  18. try {
  19. return GenerateFarmHouseConfigJson::generateJson();
  20. } catch (\Exception $e) {
  21. // 如果生成失败,返回空数组
  22. return [
  23. 'generated_ts' => time(),
  24. 'house_configs' => []
  25. ];
  26. }
  27. }
  28. /**
  29. * 获取缓存时间(秒)
  30. *
  31. * @return int
  32. */
  33. static public function getTtl(): int
  34. {
  35. return 3600; // 1小时
  36. }
  37. /**
  38. * 获取防重复执行时间(秒)
  39. *
  40. * @return int
  41. */
  42. static public function getPreventDuplication(): int
  43. {
  44. return 600; // 10分钟
  45. }
  46. /**
  47. * 获取必需参数索引
  48. *
  49. * @return array
  50. */
  51. static public function getRequiredArgIndex(): array
  52. {
  53. return [];
  54. }
  55. }