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

23 lines
556 B

2 years ago
package wechatunion
import (
"fmt"
"time"
)
2 years ago
func (c *Client) GetAccessToken() string {
if c.config.RedisClient.Db == nil {
return c.config.AccessToken
2 years ago
}
2 years ago
newCache := c.config.RedisClient.NewSimpleStringCache(c.config.RedisClient.NewStringOperation(), time.Second*7000)
2 years ago
newCache.DBGetter = func() string {
2 years ago
token := c.CgiBinToken()
2 years ago
return token.Result.AccessToken
}
2 years ago
return newCache.GetCache(c.getAccessTokenCacheKeyName())
2 years ago
}
2 years ago
func (c *Client) getAccessTokenCacheKeyName() string {
return fmt.Sprintf("wechat_access_token:%v", c.getAppId())
2 years ago
}