47 lines
936 B
Go
47 lines
936 B
Go
// Code generated by $GOPATH/src/go-common/app/tool/cache/gen. DO NOT EDIT.
|
|
|
|
/*
|
|
Package kfc is a generated cache proxy package.
|
|
It is generated from:
|
|
type _cache interface {
|
|
// cache: -sync=true
|
|
KfcCoupon(c context.Context, id int64) (*kfc.BnjKfcCoupon, error)
|
|
}
|
|
*/
|
|
|
|
package kfc
|
|
|
|
import (
|
|
"context"
|
|
|
|
"go-common/app/interface/main/activity/model/kfc"
|
|
"go-common/library/stat/prom"
|
|
)
|
|
|
|
var _ _cache
|
|
|
|
// KfcCoupon get data from cache if miss will call source method, then add to cache.
|
|
func (d *Dao) KfcCoupon(c context.Context, id int64) (res *kfc.BnjKfcCoupon, err error) {
|
|
addCache := true
|
|
res, err = d.CacheKfcCoupon(c, id)
|
|
if err != nil {
|
|
addCache = false
|
|
err = nil
|
|
}
|
|
if res != nil {
|
|
prom.CacheHit.Incr("KfcCoupon")
|
|
return
|
|
}
|
|
prom.CacheMiss.Incr("KfcCoupon")
|
|
res, err = d.RawKfcCoupon(c, id)
|
|
if err != nil {
|
|
return
|
|
}
|
|
miss := res
|
|
if !addCache {
|
|
return
|
|
}
|
|
d.AddCacheKfcCoupon(c, id, miss)
|
|
return
|
|
}
|