Browse Source

remove lock

ls 4 years ago
parent
commit
29fdb83a33
2 changed files with 4 additions and 6 deletions
  1. 3 4
      wechat/client.go
  2. 1 2
      wechat/structure.go

+ 3 - 4
wechat/client.go

@@ -4,7 +4,6 @@ import (
 	"errors"
 	"fmt"
 	"net/url"
-	"sync"
 	"time"
 
 	"git.chuangxin1.com/cx/myth"
@@ -20,15 +19,15 @@ func NewClient(appID, appSecret, token, encodingAESKey string) *Client {
 	if v, ok := cache.Load(key); ok {
 		return v.(*Client)
 	}
-	c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey, ReadLock: &sync.Mutex{}}
+	c := &Client{AppID: appID, AppSecret: appSecret, Token: token, EncodingAESKey: encodingAESKey}
 	cache.Store(key, c)
 	return c
 }
 
 // getToken get token
 func (wc *Client) getToken() (token string, err error) {
-	wc.ReadLock.Lock()
-	defer wc.ReadLock.Unlock()
+	//wc.ReadLock.Lock()
+	//defer wc.ReadLock.Unlock()
 	now := time.Now().Unix()
 	if wc.LastTokenTime > 0 {
 		if now-wc.LastTokenTime < TokenExpires {

+ 1 - 2
wechat/structure.go

@@ -2,7 +2,6 @@ package wechat
 
 import (
 	"encoding/xml"
-	"sync"
 )
 
 // FormSignature signature
@@ -199,7 +198,7 @@ type Client struct {
 	Token          string `json:"token"`
 	EncodingAESKey string `json:"encodingaeskey"`
 
-	ReadLock *sync.Mutex
+	//ReadLock *sync.Mutex
 
 	AccessToken   string
 	LastTokenTime int64