123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // Code generated by $GOPATH/src/go-common/app/tool/cache/gen. DO NOT EDIT.
- /*
- Package bws is a generated cache proxy package.
- It is generated from:
- type _cache interface {
- //cache: -sync=true
- UsersMid(c context.Context, key int64) (*bwsmdl.Users, error)
- //cache: -sync=true
- UsersKey(c context.Context, key string) (*bwsmdl.Users, error)
- //cache: -sync=true
- Points(c context.Context, bid int64) (*bwsmdl.Points, error)
- //cache: -sync=true
- Achievements(c context.Context, bid int64) (*bwsmdl.Achievements, error)
- //cache: -sync=true
- UserAchieves(c context.Context, bid int64, key string) ([]*bwsmdl.UserAchieve, error)
- //cache: -sync=true
- UserPoints(c context.Context, bid int64, key string) ([]*bwsmdl.UserPoint, error)
- //cache: -sync=true
- AchieveCounts(c context.Context, bid int64, day string) ([]*bwsmdl.CountAchieves, error)
- }
- */
- package bws
- import (
- "context"
- bwsmdl "go-common/app/interface/main/activity/model/bws"
- "go-common/library/stat/prom"
- )
- var _ _cache
- // UsersMid get data from cache if miss will call source method, then add to cache.
- func (d *Dao) UsersMid(c context.Context, id int64) (res *bwsmdl.Users, err error) {
- addCache := true
- res, err = d.CacheUsersMid(c, id)
- if err != nil {
- addCache = false
- err = nil
- }
- if res != nil {
- prom.CacheHit.Incr("UsersMid")
- return
- }
- prom.CacheMiss.Incr("UsersMid")
- res, err = d.RawUsersMid(c, id)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheUsersMid(c, id, miss)
- return
- }
- // UsersKey get data from cache if miss will call source method, then add to cache.
- func (d *Dao) UsersKey(c context.Context, id string) (res *bwsmdl.Users, err error) {
- addCache := true
- res, err = d.CacheUsersKey(c, id)
- if err != nil {
- addCache = false
- err = nil
- }
- if res != nil {
- prom.CacheHit.Incr("UsersKey")
- return
- }
- prom.CacheMiss.Incr("UsersKey")
- res, err = d.RawUsersKey(c, id)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheUsersKey(c, id, miss)
- return
- }
- // Points get data from cache if miss will call source method, then add to cache.
- func (d *Dao) Points(c context.Context, id int64) (res *bwsmdl.Points, err error) {
- addCache := true
- res, err = d.CachePoints(c, id)
- if err != nil {
- addCache = false
- err = nil
- }
- if res != nil {
- prom.CacheHit.Incr("Points")
- return
- }
- prom.CacheMiss.Incr("Points")
- res, err = d.RawPoints(c, id)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCachePoints(c, id, miss)
- return
- }
- // Achievements get data from cache if miss will call source method, then add to cache.
- func (d *Dao) Achievements(c context.Context, id int64) (res *bwsmdl.Achievements, err error) {
- addCache := true
- res, err = d.CacheAchievements(c, id)
- if err != nil {
- addCache = false
- err = nil
- }
- if res != nil {
- prom.CacheHit.Incr("Achievements")
- return
- }
- prom.CacheMiss.Incr("Achievements")
- res, err = d.RawAchievements(c, id)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheAchievements(c, id, miss)
- return
- }
- // UserAchieves get data from cache if miss will call source method, then add to cache.
- func (d *Dao) UserAchieves(c context.Context, id int64, key string) (res []*bwsmdl.UserAchieve, err error) {
- addCache := true
- res, err = d.CacheUserAchieves(c, id, key)
- if err != nil {
- addCache = false
- err = nil
- }
- if len(res) != 0 {
- prom.CacheHit.Incr("UserAchieves")
- return
- }
- prom.CacheMiss.Incr("UserAchieves")
- res, err = d.RawUserAchieves(c, id, key)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheUserAchieves(c, id, miss, key)
- return
- }
- // UserPoints get data from cache if miss will call source method, then add to cache.
- func (d *Dao) UserPoints(c context.Context, id int64, key string) (res []*bwsmdl.UserPoint, err error) {
- addCache := true
- res, err = d.CacheUserPoints(c, id, key)
- if err != nil {
- addCache = false
- err = nil
- }
- if len(res) != 0 {
- prom.CacheHit.Incr("UserPoints")
- return
- }
- prom.CacheMiss.Incr("UserPoints")
- res, err = d.RawUserPoints(c, id, key)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheUserPoints(c, id, miss, key)
- return
- }
- // AchieveCounts get data from cache if miss will call source method, then add to cache.
- func (d *Dao) AchieveCounts(c context.Context, id int64, day string) (res []*bwsmdl.CountAchieves, err error) {
- addCache := true
- res, err = d.CacheAchieveCounts(c, id, day)
- if err != nil {
- addCache = false
- err = nil
- }
- if len(res) != 0 {
- prom.CacheHit.Incr("AchieveCounts")
- return
- }
- prom.CacheMiss.Incr("AchieveCounts")
- res, err = d.RawAchieveCounts(c, id, day)
- if err != nil {
- return
- }
- miss := res
- if !addCache {
- return
- }
- d.AddCacheAchieveCounts(c, id, miss, day)
- return
- }
|