12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- // Code generated by $GOPATH/src/go-common/app/tool/cache/mc. DO NOT EDIT.
- /*
- Package roomNotice is a generated mc cache package.
- It is generated from:
- type _mc interface {
- // 获取某个月消费
- // mc: -key=keyShouldNotice
- CacheMonthConsume(c context.Context, UID int64, targetID int64, date string) (*roomNotice.MonthConsume, error)
- // 保存获取某个月消费
- // mc: -key=keyShouldNotice -expire=d.keyShouldNoticeExpire -encode=json|gzip
- AddCacheMonthConsume(c context.Context, UID int64, targetID int64, date string, value *roomNotice.MonthConsume) error
- }
- */
- package notice
- import (
- "context"
- "fmt"
- "go-common/app/service/live/xuserex/model/roomNotice"
- "go-common/library/cache/memcache"
- "go-common/library/log"
- "go-common/library/stat/prom"
- )
- var _ _mc
- // CacheMonthConsume 获取某个月消费
- func (d *Dao) CacheMonthConsume(c context.Context, id int64, targetID int64, date string) (res *roomNotice.MonthConsume, err error) {
- conn := d.mc.Get(c)
- defer conn.Close()
- key := keyShouldNotice(id, targetID, date)
- reply, err := conn.Get(key)
- if err != nil {
- if err == memcache.ErrNotFound {
- err = nil
- return
- }
- prom.BusinessErrCount.Incr("mc:CacheMonthConsume")
- log.Errorv(c, log.KV("CacheMonthConsume", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- res = &roomNotice.MonthConsume{}
- err = conn.Scan(reply, res)
- if err != nil {
- prom.BusinessErrCount.Incr("mc:CacheMonthConsume")
- log.Errorv(c, log.KV("CacheMonthConsume", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- return
- }
- // AddCacheMonthConsume 保存获取某个月消费
- func (d *Dao) AddCacheMonthConsume(c context.Context, id int64, targetID int64, date string, value *roomNotice.MonthConsume) (err error) {
- conn := d.mc.Get(c)
- defer conn.Close()
- key := keyShouldNotice(id, targetID, date)
- item := &memcache.Item{Key: key, Object: value, Expiration: keyShouldNoticeExpire, Flags: memcache.FlagJSON}
- if err = conn.Set(item); err != nil {
- prom.BusinessErrCount.Incr("mc:AddCacheMonthConsume")
- log.Errorv(c, log.KV("AddCacheMonthConsume", fmt.Sprintf("%+v", err)), log.KV("key", key))
- return
- }
- return
- }
|