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/wechatminiprogram/cgi-bin.token.rdb.go

21 lines
485 B

package wechatminiprogram
import (
"fmt"
"github.com/dtapps/go-library/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.Second*7000)
newCache.DBGetter = func() string {
token := app.AuthGetAccessToken()
return token.Result.AccessToken
}
return newCache.GetCache(cacheName)
}