123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- // Code generated by $GOPATH/src/go-common/app/tool/cache/gen. DO NOT EDIT.
- /*
- Package dao is a generated cache proxy package.
- It is generated from:
- type _cache interface {
- // cache
- EpContests(c context.Context, ids []int64) (map[int64]*model.Contest, error)
- // cache
- EpSeasons(c context.Context, ids []int64) (map[int64]*model.Season, error)
- // cache
- EpTeams(c context.Context, ids []int64) (map[int64]*model.Team, error)
- // cache
- EpContestsData(c context.Context, ids []int64) (map[int64][]*model.ContestsData, error)
- }
- */
- package dao
- import (
- "context"
- "go-common/app/interface/main/esports/model"
- "go-common/library/stat/prom"
- )
- var _ _cache
- // EpContests get data from cache if miss will call source method, then add to cache.
- func (d *Dao) EpContests(c context.Context, keys []int64) (res map[int64]*model.Contest, err error) {
- if len(keys) == 0 {
- return
- }
- addCache := true
- if res, err = d.CacheEpContests(c, keys); err != nil {
- addCache = false
- res = nil
- err = nil
- }
- var miss []int64
- for _, key := range keys {
- if (res == nil) || (res[key] == nil) {
- miss = append(miss, key)
- }
- }
- prom.CacheHit.Add("EpContests", int64(len(keys)-len(miss)))
- missLen := len(miss)
- if missLen == 0 {
- return
- }
- var missData map[int64]*model.Contest
- prom.CacheMiss.Add("EpContests", int64(len(miss)))
- missData, err = d.RawEpContests(c, miss)
- if res == nil {
- res = make(map[int64]*model.Contest, len(keys))
- }
- for k, v := range missData {
- res[k] = v
- }
- if err != nil {
- return
- }
- if !addCache {
- return
- }
- d.cache.Do(c, func(c context.Context) {
- d.AddCacheEpContests(c, missData)
- })
- return
- }
- // EpSeasons get data from cache if miss will call source method, then add to cache.
- func (d *Dao) EpSeasons(c context.Context, keys []int64) (res map[int64]*model.Season, err error) {
- if len(keys) == 0 {
- return
- }
- addCache := true
- if res, err = d.CacheEpSeasons(c, keys); err != nil {
- addCache = false
- res = nil
- err = nil
- }
- var miss []int64
- for _, key := range keys {
- if (res == nil) || (res[key] == nil) {
- miss = append(miss, key)
- }
- }
- prom.CacheHit.Add("EpSeasons", int64(len(keys)-len(miss)))
- missLen := len(miss)
- if missLen == 0 {
- return
- }
- var missData map[int64]*model.Season
- prom.CacheMiss.Add("EpSeasons", int64(len(miss)))
- missData, err = d.RawEpSeasons(c, miss)
- if res == nil {
- res = make(map[int64]*model.Season, len(keys))
- }
- for k, v := range missData {
- res[k] = v
- }
- if err != nil {
- return
- }
- if !addCache {
- return
- }
- d.cache.Do(c, func(c context.Context) {
- d.AddCacheEpSeasons(c, missData)
- })
- return
- }
- // EpTeams get data from cache if miss will call source method, then add to cache.
- func (d *Dao) EpTeams(c context.Context, keys []int64) (res map[int64]*model.Team, err error) {
- if len(keys) == 0 {
- return
- }
- addCache := true
- if res, err = d.CacheEpTeams(c, keys); err != nil {
- addCache = false
- res = nil
- err = nil
- }
- var miss []int64
- for _, key := range keys {
- if (res == nil) || (res[key] == nil) {
- miss = append(miss, key)
- }
- }
- prom.CacheHit.Add("EpTeams", int64(len(keys)-len(miss)))
- missLen := len(miss)
- if missLen == 0 {
- return
- }
- var missData map[int64]*model.Team
- prom.CacheMiss.Add("EpTeams", int64(len(miss)))
- missData, err = d.RawEpTeams(c, miss)
- if res == nil {
- res = make(map[int64]*model.Team, len(keys))
- }
- for k, v := range missData {
- res[k] = v
- }
- if err != nil {
- return
- }
- if !addCache {
- return
- }
- d.cache.Do(c, func(c context.Context) {
- d.AddCacheEpTeams(c, missData)
- })
- return
- }
|