cache.go 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. package channel
  2. import (
  3. "context"
  4. "time"
  5. "go-common/app/interface/main/app-card/model/card/operate"
  6. "go-common/app/interface/main/app-channel/model/card"
  7. "go-common/app/interface/main/app-channel/model/tab"
  8. "go-common/library/log"
  9. )
  10. // loadCardCache card cache
  11. func (s *Service) loadCardCache(now time.Time) {
  12. var (
  13. tmp = map[int64][]*card.Card{}
  14. tmpPlat = map[string][]*card.CardPlat{}
  15. tmpUp = map[int64]*operate.Follow{}
  16. err error
  17. c = context.TODO()
  18. )
  19. if tmp, err = s.cd.Card(c, now); err != nil {
  20. log.Error("card s.cd.Card error(%v)", err)
  21. return
  22. }
  23. s.cardCache = tmp
  24. log.Info("loadCardCache success")
  25. if tmpPlat, err = s.cd.CardPlat(c); err != nil {
  26. log.Error("card s.cd.CardPlat error(%v)", err)
  27. return
  28. }
  29. s.cardPlatCache = tmpPlat
  30. log.Info("loadCardPlatCache success")
  31. if tmpUp, err = s.cd.UpCard(c); err != nil {
  32. log.Error("card s.cd.UpCard error(%v)", err)
  33. return
  34. }
  35. s.upCardCache = tmpUp
  36. log.Info("loadUpCardCache success")
  37. }
  38. func (s *Service) loadConvergeCache() {
  39. var (
  40. tmp = map[int64]*operate.Converge{}
  41. err error
  42. c = context.TODO()
  43. )
  44. if tmp, err = s.ce.Cards(c); err != nil {
  45. log.Error("converge s.ce.Cards error(%v)", err)
  46. return
  47. }
  48. s.convergeCardCache = tmp
  49. log.Info("loadConvergeCache success")
  50. }
  51. func (s *Service) loadSpecialCache() {
  52. var (
  53. tmp = map[int64]*operate.Special{}
  54. err error
  55. c = context.TODO()
  56. )
  57. if tmp, err = s.sl.Card(c); err != nil {
  58. log.Error("special s.sl.Card error(%v)", err)
  59. return
  60. }
  61. s.specialCardCache = tmp
  62. log.Info("loadSpecialCache success")
  63. }
  64. func (s *Service) loadLiveCardCache() {
  65. csm, err := s.lv.Card(context.TODO())
  66. if err != nil {
  67. log.Error("live s.lv.Card error(%v)", err)
  68. return
  69. }
  70. s.liveCardCache = csm
  71. log.Info("loadLiveCardCache success")
  72. }
  73. func (s *Service) loadGameDownloadCache() {
  74. var (
  75. download map[int64]*operate.Download
  76. err error
  77. )
  78. c := context.TODO()
  79. if download, err = s.g.DownLoad(c); err != nil {
  80. log.Error("%+v", err)
  81. return
  82. }
  83. s.gameDownloadCache = download
  84. }
  85. func (s *Service) loadCardSetCache() {
  86. var (
  87. cards map[int64]*operate.CardSet
  88. err error
  89. )
  90. if cards, err = s.cd.CardSet(context.TODO()); err != nil {
  91. log.Error("%+v", err)
  92. return
  93. }
  94. s.cardSetCache = cards
  95. }
  96. func (s *Service) loadMenusCache(now time.Time) {
  97. var (
  98. menus map[int64][]*tab.Menu
  99. err error
  100. )
  101. if menus, err = s.tab.Menus(context.TODO(), now); err != nil {
  102. log.Error("%+v", err)
  103. return
  104. }
  105. s.menuCache = menus
  106. }