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.
23 lines
518 B
23 lines
518 B
package wechatoffice
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
func (app *App) GetAccessToken() string {
|
|
if app.redis.Db == nil {
|
|
return app.accessToken
|
|
}
|
|
newCache := app.redis.NewSimpleStringCache(app.redis.NewStringOperation(), time.Second*7000)
|
|
newCache.DBGetter = func() string {
|
|
token := app.CgiBinToken()
|
|
return token.Result.AccessToken
|
|
}
|
|
return newCache.GetCache(app.getAccessTokenCacheKeyName())
|
|
}
|
|
|
|
func (app *App) getAccessTokenCacheKeyName() string {
|
|
return fmt.Sprintf("wechat_access_token:%v", app.appId)
|
|
}
|