1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- // Code generated by $GOPATH/src/go-common/app/tool/cache/mc. DO NOT EDIT.
- /*
- Package anchorReward is a generated mc cache package.
- It is generated from:
- type _mc interface {
- // 获取奖励配置
- // mc: -key=keyRewardConf
- CacheRewardConf(c context.Context, id int64) (*model.AnchorRewardConf, error)
- // 保存奖励配置
- // mc: -key=keyRewardConf -expire=d.keyRewardConfExpire -encode=json|gzip
- AddCacheRewardConf(c context.Context, id int64, value *model.AnchorRewardConf) error
- }
- */
- package anchorReward
- import (
- "context"
- "fmt"
- model "go-common/app/service/live/xrewardcenter/model/anchorTask"
- "go-common/library/cache/memcache"
- "go-common/library/log"
- "go-common/library/stat/prom"
- )
- var _ _mc
- // CacheRewardConf 获取奖励配置
- func (d *Dao) CacheRewardConf(c context.Context, id int64) (res *model.AnchorRewardConf, err error) {
- conn := d.mc.Get(c)
- defer conn.Close()
- key := keyRewardConf(id)
- reply, err := conn.Get(key)
- if err != nil {
- if err == memcache.ErrNotFound {
- err = nil
- return
- }
- prom.BusinessErrCount.Incr("mc:CacheRewardConf")
- log.Errorv(c, log.KV("CacheRewardConf", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- res = &model.AnchorRewardConf{}
- err = conn.Scan(reply, res)
- if err != nil {
- prom.BusinessErrCount.Incr("mc:CacheRewardConf")
- log.Errorv(c, log.KV("CacheRewardConf", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- return
- }
- // AddCacheRewardConf 保存奖励配置
- func (d *Dao) AddCacheRewardConf(c context.Context, id int64, val *model.AnchorRewardConf) (err error) {
- if val == nil {
- return
- }
- conn := d.mc.Get(c)
- defer conn.Close()
- key := keyRewardConf(id)
- item := &memcache.Item{Key: key, Object: val, Expiration: d.keyRewardConfExpire, Flags: memcache.FlagJSON | memcache.FlagGzip}
- if err = conn.Set(item); err != nil {
- prom.BusinessErrCount.Incr("mc:AddCacheRewardConf")
- log.Errorv(c, log.KV("AddCacheRewardConf", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- return
- }
|