72 lines
2.0 KiB
Go
72 lines
2.0 KiB
Go
// 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
|
|
}
|