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/wechatoffice/getticket.rdb.go

22 lines
536 B

package wechatoffice
import (
"fmt"
"github.com/dtapps/go-library/utils/goredis"
"time"
)
// GetJsapiTicketRDb 获取api_ticket
func (app *App) GetJsapiTicketRDb() string {
cacheName := fmt.Sprintf("wechat_jsapi_ticket:%v", app.AppId)
redis := goredis.App{
Rdb: app.RDb,
}
newCache := redis.NewSimpleStringCache(redis.NewStringOperation(), time.Second*7000)
newCache.DBGetter = func() string {
token := app.GetTicket(app.GetAccessTokenRDb(), "jsapi")
return token.Result.Ticket
}
return newCache.GetCache(cacheName)
}