You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1010 B
49 lines
1010 B
// Code generated by $GOPATH/src/go-common/app/tool/cache/gen. DO NOT EDIT. |
|
|
|
/* |
|
Package wechat is a generated cache proxy package. |
|
It is generated from: |
|
type _cache interface { |
|
// cache |
|
AccessToken(c context.Context) (*wechat.AccessToken, error) |
|
} |
|
*/ |
|
|
|
package wechat |
|
|
|
import ( |
|
"context" |
|
|
|
"go-common/app/interface/main/web-goblin/model/wechat" |
|
"go-common/library/net/metadata" |
|
"go-common/library/stat/prom" |
|
) |
|
|
|
var _ _cache |
|
|
|
// AccessToken get data from cache if miss will call source method, then add to cache. |
|
func (d *Dao) AccessToken(c context.Context) (res *wechat.AccessToken, err error) { |
|
addCache := true |
|
res, err = d.CacheAccessToken(c) |
|
if err != nil { |
|
addCache = false |
|
err = nil |
|
} |
|
if res != nil { |
|
prom.CacheHit.Incr("AccessToken") |
|
return |
|
} |
|
prom.CacheMiss.Incr("AccessToken") |
|
res, err = d.RawAccessToken(c) |
|
if err != nil { |
|
return |
|
} |
|
var miss = res |
|
if !addCache { |
|
return |
|
} |
|
d.cache.Save(func() { |
|
d.AddCacheAccessToken(metadata.WithContext(c), miss) |
|
}) |
|
return |
|
}
|
|
|