FarmSeedJsonConfig.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace App\Module\Game\DCache;
  3. use App\Module\Farm\Commands\GenerateFarmSeedConfigJson;
  4. use App\Module\LCache\DQueueJob;
  5. /**
  6. * 农场种子配置表缓存
  7. */
  8. class FarmSeedJsonConfig 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 GenerateFarmSeedConfigJson::generateJson();
  20. } catch (\Exception $e) {
  21. // 如果生成失败,返回空数组
  22. return [
  23. 'generated_ts' => time(),
  24. 'seeds' => [],
  25. 'fruit_growth_cycles' => []
  26. ];
  27. }
  28. }
  29. /**
  30. * 获取缓存时间(秒)
  31. *
  32. * @return int
  33. */
  34. static public function getTtl(): int
  35. {
  36. return 3600; // 1小时
  37. }
  38. /**
  39. * 获取防重复执行时间(秒)
  40. *
  41. * @return int
  42. */
  43. static public function getPreventDuplication(): int
  44. {
  45. return 600; // 10分钟
  46. }
  47. /**
  48. * 获取必需参数索引
  49. *
  50. * @return array
  51. */
  52. static public function getRequiredArgIndex(): array
  53. {
  54. return [];
  55. }
  56. }