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.
24 lines
565 B
24 lines
565 B
package wechatoffice
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// GetJsapiTicket 获取api_ticket
|
|
func (app *App) GetJsapiTicket() string {
|
|
if app.Redis.Db == nil {
|
|
return app.JsapiTicket
|
|
}
|
|
newCache := app.Redis.NewSimpleStringCache(app.Redis.NewStringOperation(), time.Second*7000)
|
|
newCache.DBGetter = func() string {
|
|
token := app.CgiBinTicketGetTicket("jsapi")
|
|
return token.Result.Ticket
|
|
}
|
|
return newCache.GetCache(app.getJsapiTicketCacheKeyName())
|
|
}
|
|
|
|
func (app *App) getJsapiTicketCacheKeyName() string {
|
|
return fmt.Sprintf("wechat_jsapi_ticket:%v", app.AppId)
|
|
}
|