288 lines
9.1 KiB
Go
288 lines
9.1 KiB
Go
|
// Code generated by $GOPATH/src/go-common/app/tool/cache/mc. DO NOT EDIT.
|
||
|
|
||
|
/*
|
||
|
Package mcndao is a generated mc cache package.
|
||
|
It is generated from:
|
||
|
type _mc interface {
|
||
|
//mc: -key=mcnSignCacheKey -expire=d.mcnSignExpire -encode=json
|
||
|
AddCacheMcnSign(c context.Context, mcnmid int64, up *mcnmodel.McnSign) (err error)
|
||
|
//mc: -key=mcnSignCacheKey
|
||
|
CacheMcnSign(c context.Context, mcnmid int64) (up *mcnmodel.McnSign, err error)
|
||
|
//mc: -key=mcnSignCacheKey
|
||
|
DelCacheMcnSign(c context.Context, mcnmid int64) (err error)
|
||
|
|
||
|
//mc: -key=mcnDataCacheKey -expire=d.mcnDataExpire -encode=json
|
||
|
AddCacheMcnDataSummary(c context.Context, mcnmid int64, data *mcnmodel.McnGetDataSummaryReply, generateDate time.Time) (err error)
|
||
|
//mc: -key=mcnDataCacheKey
|
||
|
CacheMcnDataSummary(c context.Context, mcnmid int64, generateDate time.Time) (data *mcnmodel.McnGetDataSummaryReply, err error)
|
||
|
//mc: -key=mcnDataCacheKey
|
||
|
DelMcnDataSummary(c context.Context, mcnmid int64, generateDate time.Time) (err error)
|
||
|
|
||
|
//mc: -key=mcnPublicationPriceKey -expire=0 -encode=json
|
||
|
AddCachePublicationPrice(c context.Context, signID int64, data *mcnmodel.PublicationPriceCache, mid int64) (err error)
|
||
|
//mc: -key=mcnPublicationPriceKey
|
||
|
CachePublicationPrice(c context.Context, signID int64, mid int64) (data *mcnmodel.PublicationPriceCache, err error)
|
||
|
//mc: -key=mcnPublicationPriceKey
|
||
|
DelPublicationPrice(c context.Context, signID int64, mid int64) (err error)
|
||
|
|
||
|
//mc: -key=mcnUpPermissionKey -expire=d.mcnSignExpire -encode=json
|
||
|
AddCacheUpPermission(c context.Context, signID int64, data *mcnmodel.UpPermissionCache, mid int64) (err error)
|
||
|
//mc: -key=mcnUpPermissionKey
|
||
|
CacheUpPermission(c context.Context, signID int64, mid int64) (data *mcnmodel.UpPermissionCache, err error)
|
||
|
//mc: -key=mcnUpPermissionKey
|
||
|
DelUpPermission(c context.Context, signID int64, mid int64) (err error)
|
||
|
|
||
|
}
|
||
|
*/
|
||
|
|
||
|
package mcndao
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"fmt"
|
||
|
|
||
|
"go-common/app/interface/main/mcn/model/mcnmodel"
|
||
|
"go-common/library/cache/memcache"
|
||
|
"go-common/library/log"
|
||
|
"go-common/library/stat/prom"
|
||
|
"time"
|
||
|
)
|
||
|
|
||
|
var _ _mc
|
||
|
|
||
|
// AddCacheMcnSign Set data to mc
|
||
|
func (d *Dao) AddCacheMcnSign(c context.Context, id int64, val *mcnmodel.McnSign) (err error) {
|
||
|
if val == nil {
|
||
|
return
|
||
|
}
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnSignCacheKey(id)
|
||
|
item := &memcache.Item{Key: key, Object: val, Expiration: d.mcnSignExpire, Flags: memcache.FlagJSON}
|
||
|
if err = conn.Set(item); err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:AddCacheMcnSign")
|
||
|
log.Errorv(c, log.KV("AddCacheMcnSign", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CacheMcnSign get data from mc
|
||
|
func (d *Dao) CacheMcnSign(c context.Context, id int64) (res *mcnmodel.McnSign, err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnSignCacheKey(id)
|
||
|
reply, err := conn.Get(key)
|
||
|
if err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:CacheMcnSign")
|
||
|
log.Errorv(c, log.KV("CacheMcnSign", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
res = &mcnmodel.McnSign{}
|
||
|
err = conn.Scan(reply, res)
|
||
|
if err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:CacheMcnSign")
|
||
|
log.Errorv(c, log.KV("CacheMcnSign", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// DelCacheMcnSign delete data from mc
|
||
|
func (d *Dao) DelCacheMcnSign(c context.Context, id int64) (err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnSignCacheKey(id)
|
||
|
if err = conn.Delete(key); err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:DelCacheMcnSign")
|
||
|
log.Errorv(c, log.KV("DelCacheMcnSign", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// AddCacheMcnDataSummary Set data to mc
|
||
|
func (d *Dao) AddCacheMcnDataSummary(c context.Context, id int64, val *mcnmodel.McnGetDataSummaryReply, generateDate time.Time) (err error) {
|
||
|
if val == nil {
|
||
|
return
|
||
|
}
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnDataCacheKey(id, generateDate)
|
||
|
item := &memcache.Item{Key: key, Object: val, Expiration: d.mcnDataExpire, Flags: memcache.FlagJSON}
|
||
|
if err = conn.Set(item); err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:AddCacheMcnDataSummary")
|
||
|
log.Errorv(c, log.KV("AddCacheMcnDataSummary", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CacheMcnDataSummary get data from mc
|
||
|
func (d *Dao) CacheMcnDataSummary(c context.Context, id int64, generateDate time.Time) (res *mcnmodel.McnGetDataSummaryReply, err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnDataCacheKey(id, generateDate)
|
||
|
reply, err := conn.Get(key)
|
||
|
if err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:CacheMcnDataSummary")
|
||
|
log.Errorv(c, log.KV("CacheMcnDataSummary", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
res = &mcnmodel.McnGetDataSummaryReply{}
|
||
|
err = conn.Scan(reply, res)
|
||
|
if err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:CacheMcnDataSummary")
|
||
|
log.Errorv(c, log.KV("CacheMcnDataSummary", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// DelMcnDataSummary delete data from mc
|
||
|
func (d *Dao) DelMcnDataSummary(c context.Context, id int64, generateDate time.Time) (err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnDataCacheKey(id, generateDate)
|
||
|
if err = conn.Delete(key); err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:DelMcnDataSummary")
|
||
|
log.Errorv(c, log.KV("DelMcnDataSummary", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// AddCachePublicationPrice Set data to mc
|
||
|
func (d *Dao) AddCachePublicationPrice(c context.Context, id int64, val *mcnmodel.PublicationPriceCache, mid int64) (err error) {
|
||
|
if val == nil {
|
||
|
return
|
||
|
}
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnPublicationPriceKey(id, mid)
|
||
|
item := &memcache.Item{Key: key, Object: val, Expiration: 0, Flags: memcache.FlagJSON}
|
||
|
if err = conn.Set(item); err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:AddCachePublicationPrice")
|
||
|
log.Errorv(c, log.KV("AddCachePublicationPrice", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CachePublicationPrice get data from mc
|
||
|
func (d *Dao) CachePublicationPrice(c context.Context, id int64, mid int64) (res *mcnmodel.PublicationPriceCache, err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnPublicationPriceKey(id, mid)
|
||
|
reply, err := conn.Get(key)
|
||
|
if err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:CachePublicationPrice")
|
||
|
log.Errorv(c, log.KV("CachePublicationPrice", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
res = &mcnmodel.PublicationPriceCache{}
|
||
|
err = conn.Scan(reply, res)
|
||
|
if err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:CachePublicationPrice")
|
||
|
log.Errorv(c, log.KV("CachePublicationPrice", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// DelPublicationPrice delete data from mc
|
||
|
func (d *Dao) DelPublicationPrice(c context.Context, id int64, mid int64) (err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnPublicationPriceKey(id, mid)
|
||
|
if err = conn.Delete(key); err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:DelPublicationPrice")
|
||
|
log.Errorv(c, log.KV("DelPublicationPrice", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// AddCacheUpPermission Set data to mc
|
||
|
func (d *Dao) AddCacheUpPermission(c context.Context, id int64, val *mcnmodel.UpPermissionCache, mid int64) (err error) {
|
||
|
if val == nil {
|
||
|
return
|
||
|
}
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnUpPermissionKey(id, mid)
|
||
|
item := &memcache.Item{Key: key, Object: val, Expiration: d.mcnSignExpire, Flags: memcache.FlagJSON}
|
||
|
if err = conn.Set(item); err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:AddCacheUpPermission")
|
||
|
log.Errorv(c, log.KV("AddCacheUpPermission", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// CacheUpPermission get data from mc
|
||
|
func (d *Dao) CacheUpPermission(c context.Context, id int64, mid int64) (res *mcnmodel.UpPermissionCache, err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnUpPermissionKey(id, mid)
|
||
|
reply, err := conn.Get(key)
|
||
|
if err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:CacheUpPermission")
|
||
|
log.Errorv(c, log.KV("CacheUpPermission", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
res = &mcnmodel.UpPermissionCache{}
|
||
|
err = conn.Scan(reply, res)
|
||
|
if err != nil {
|
||
|
prom.BusinessErrCount.Incr("mc:CacheUpPermission")
|
||
|
log.Errorv(c, log.KV("CacheUpPermission", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|
||
|
|
||
|
// DelUpPermission delete data from mc
|
||
|
func (d *Dao) DelUpPermission(c context.Context, id int64, mid int64) (err error) {
|
||
|
conn := d.mc.Get(c)
|
||
|
defer conn.Close()
|
||
|
key := mcnUpPermissionKey(id, mid)
|
||
|
if err = conn.Delete(key); err != nil {
|
||
|
if err == memcache.ErrNotFound {
|
||
|
err = nil
|
||
|
return
|
||
|
}
|
||
|
prom.BusinessErrCount.Incr("mc:DelUpPermission")
|
||
|
log.Errorv(c, log.KV("DelUpPermission", fmt.Sprintf("%+v", err)), log.KV("key", key))
|
||
|
return
|
||
|
}
|
||
|
return
|
||
|
}
|