48 lines
900 B
Go
48 lines
900 B
Go
|
// 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 {
|
||
|
GameList(c context.Context) (res []int64, err error)
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
package dao
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
"go-common/library/net/metadata"
|
||
|
"go-common/library/stat/prom"
|
||
|
)
|
||
|
|
||
|
var _ _cache
|
||
|
|
||
|
// GameList get data from cache if miss will call source method, then add to cache.
|
||
|
func (d *Dao) GameList(c context.Context) (res []int64, err error) {
|
||
|
addCache := true
|
||
|
res, err = d.CacheGameList(c)
|
||
|
if err != nil {
|
||
|
addCache = false
|
||
|
err = nil
|
||
|
}
|
||
|
if len(res) != 0 {
|
||
|
prom.CacheHit.Incr("GameList")
|
||
|
return
|
||
|
}
|
||
|
prom.CacheMiss.Incr("GameList")
|
||
|
res, err = d.RawGameList(c)
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
var miss = res
|
||
|
if !addCache {
|
||
|
return
|
||
|
}
|
||
|
d.cache.Save(func() {
|
||
|
d.AddCacheGameList(metadata.WithContext(c), miss)
|
||
|
})
|
||
|
return
|
||
|
}
|