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.
go-library/service/wechatunion/cgi-bin.token.rdb.go

21 lines
480 B

package wechatunion
import (
"fmt"
"gopkg.in/dtapps/go-library.v3/utils/goredis"
"time"
)
func (app *App) GetAccessTokenRDb() string {
cacheName := fmt.Sprintf("wechat_access_token:%v", app.AppId)
redis := goredis.App{
Rdb: app.RDb,
}
newCache := redis.NewSimpleStringCache(redis.NewStringOperation(), time.Minute*7000)
newCache.DBGetter = func() string {
token := app.AuthGetAccessToken()
return token.Result.AccessToken
}
return newCache.GetCache(cacheName)
}