|
@@ -12,7 +12,7 @@ import (
|
|
"git.chuangxin1.com/cx/myth"
|
|
"git.chuangxin1.com/cx/myth"
|
|
)
|
|
)
|
|
|
|
|
|
-func key(appid string) string {
|
|
|
|
|
|
+func keyC(appid string) string {
|
|
return "wechat:client:" + appid
|
|
return "wechat:client:" + appid
|
|
}
|
|
}
|
|
|
|
|
|
@@ -22,7 +22,7 @@ func keyToken(appid string) string {
|
|
|
|
|
|
// NewClient new client
|
|
// NewClient new client
|
|
func NewClient(appID, appSecret, token, encodingAESKey string) *Client {
|
|
func NewClient(appID, appSecret, token, encodingAESKey string) *Client {
|
|
- key := key(appID)
|
|
|
|
|
|
+ key := keyC(appID)
|
|
if v, ok := memcache.Load(key); ok {
|
|
if v, ok := memcache.Load(key); ok {
|
|
return v.(*Client)
|
|
return v.(*Client)
|
|
}
|
|
}
|
|
@@ -73,7 +73,7 @@ func (wc *Client) getToken() (token string, err error) {
|
|
wc.AccessToken = accessToken
|
|
wc.AccessToken = accessToken
|
|
token = wc.AccessToken
|
|
token = wc.AccessToken
|
|
|
|
|
|
- key1 := key(wc.AppID)
|
|
|
|
|
|
+ key1 := keyC(wc.AppID)
|
|
memcache.Store(key1, wc)
|
|
memcache.Store(key1, wc)
|
|
ct := ClientToken{AppID: wc.AppID, AccessToken: wc.AccessToken, LastTokenTime: now}
|
|
ct := ClientToken{AppID: wc.AppID, AccessToken: wc.AccessToken, LastTokenTime: now}
|
|
bs, _ := json.Marshal(ct)
|
|
bs, _ := json.Marshal(ct)
|
|
@@ -103,7 +103,7 @@ func (wc *Client) getTicket(now int64) (ticket string, err error) {
|
|
wc.LastTicketTime = now
|
|
wc.LastTicketTime = now
|
|
wc.Ticket = ticket
|
|
wc.Ticket = ticket
|
|
|
|
|
|
- key := key(wc.AppID)
|
|
|
|
|
|
+ key := keyC(wc.AppID)
|
|
memcache.Store(key, wc)
|
|
memcache.Store(key, wc)
|
|
}
|
|
}
|
|
|
|
|