134 lines
3.1 KiB
Go
134 lines
3.1 KiB
Go
// Code generated by $GOPATH/src/go-common/app/tool/cache/gen. DO NOT EDIT.
|
|
|
|
/*
|
|
Package mcndao is a generated cache proxy package.
|
|
It is generated from:
|
|
type _cache interface {
|
|
//cache: -nullcache=&mcnmodel.McnSign{ID:-1} -check_null_code=$!=nil&&$.ID==-1
|
|
McnSign(c context.Context, mcnmid int64) (up *mcnmodel.McnSign, err error)
|
|
|
|
//cache: -nullcache=&mcnmodel.McnGetDataSummaryReply{IsNull:true} -check_null_code=$!=nil&&$.IsNull
|
|
McnDataSummary(c context.Context, mcnmid int64, generateDate time.Time) (res *mcnmodel.McnGetDataSummaryReply, err error)
|
|
|
|
//cache: -nullcache=&mcnmodel.UpPermissionCache{IsNull:true} -check_null_code=$!=nil&&$.IsNull
|
|
UpPermission(c context.Context, signID int64, mid int64) (data *mcnmodel.UpPermissionCache, err error)
|
|
}
|
|
*/
|
|
|
|
package mcndao
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go-common/app/interface/main/mcn/model/mcnmodel"
|
|
"go-common/library/stat/prom"
|
|
"time"
|
|
)
|
|
|
|
var _ _cache
|
|
|
|
// McnSign get data from cache if miss will call source method, then add to cache.
|
|
func (d *Dao) McnSign(c context.Context, id int64) (res *mcnmodel.McnSign, err error) {
|
|
addCache := true
|
|
res, err = d.CacheMcnSign(c, id)
|
|
if err != nil {
|
|
addCache = false
|
|
err = nil
|
|
}
|
|
defer func() {
|
|
if res != nil && res.ID == -1 {
|
|
res = nil
|
|
}
|
|
}()
|
|
if res != nil {
|
|
prom.CacheHit.Incr("McnSign")
|
|
return
|
|
}
|
|
prom.CacheMiss.Incr("McnSign")
|
|
res, err = d.RawMcnSign(c, id)
|
|
if err != nil {
|
|
return
|
|
}
|
|
miss := res
|
|
if miss == nil {
|
|
miss = &mcnmodel.McnSign{ID: -1}
|
|
}
|
|
if !addCache {
|
|
return
|
|
}
|
|
d.cache.Do(c, func(c context.Context) {
|
|
d.AddCacheMcnSign(c, id, miss)
|
|
})
|
|
return
|
|
}
|
|
|
|
// McnDataSummary get data from cache if miss will call source method, then add to cache.
|
|
func (d *Dao) McnDataSummary(c context.Context, id int64, generateDate time.Time) (res *mcnmodel.McnGetDataSummaryReply, err error) {
|
|
addCache := true
|
|
res, err = d.CacheMcnDataSummary(c, id, generateDate)
|
|
if err != nil {
|
|
addCache = false
|
|
err = nil
|
|
}
|
|
defer func() {
|
|
if res != nil && res.IsNull {
|
|
res = nil
|
|
}
|
|
}()
|
|
if res != nil {
|
|
prom.CacheHit.Incr("McnDataSummary")
|
|
return
|
|
}
|
|
prom.CacheMiss.Incr("McnDataSummary")
|
|
res, err = d.RawMcnDataSummary(c, id, generateDate)
|
|
if err != nil {
|
|
return
|
|
}
|
|
miss := res
|
|
if miss == nil {
|
|
miss = &mcnmodel.McnGetDataSummaryReply{IsNull: true}
|
|
}
|
|
if !addCache {
|
|
return
|
|
}
|
|
d.cache.Do(c, func(c context.Context) {
|
|
d.AddCacheMcnDataSummary(c, id, miss, generateDate)
|
|
})
|
|
return
|
|
}
|
|
|
|
// UpPermission get data from cache if miss will call source method, then add to cache.
|
|
func (d *Dao) UpPermission(c context.Context, id int64, mid int64) (res *mcnmodel.UpPermissionCache, err error) {
|
|
addCache := true
|
|
res, err = d.CacheUpPermission(c, id, mid)
|
|
if err != nil {
|
|
addCache = false
|
|
err = nil
|
|
}
|
|
defer func() {
|
|
if res != nil && res.IsNull {
|
|
res = nil
|
|
}
|
|
}()
|
|
if res != nil {
|
|
prom.CacheHit.Incr("UpPermission")
|
|
return
|
|
}
|
|
prom.CacheMiss.Incr("UpPermission")
|
|
res, err = d.RawUpPermission(c, id, mid)
|
|
if err != nil {
|
|
return
|
|
}
|
|
miss := res
|
|
if miss == nil {
|
|
miss = &mcnmodel.UpPermissionCache{IsNull: true}
|
|
}
|
|
if !addCache {
|
|
return
|
|
}
|
|
d.cache.Do(c, func(c context.Context) {
|
|
d.AddCacheUpPermission(c, id, miss, mid)
|
|
})
|
|
return
|
|
}
|