|
|
@@ -2,6 +2,7 @@ package utils
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
+ "fmt"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
@@ -14,6 +15,7 @@ import (
|
|
|
type TokenStore interface {
|
|
|
Get(string) *entitys.Token
|
|
|
Set(string, *entitys.Token)
|
|
|
+ SetPc(string, *entitys.Token)
|
|
|
Remove(key string)
|
|
|
Refresh(key string) *entitys.Token
|
|
|
}
|
|
|
@@ -59,6 +61,16 @@ func (t *MemoryStore) Set(key string, v *entitys.Token) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func (t *MemoryStore) SetPc(key string, v *entitys.Token) {
|
|
|
+ t.lock.Lock()
|
|
|
+ defer t.lock.Unlock()
|
|
|
+ if val, ok := t.tokens[key]; !ok {
|
|
|
+ t.tokens[key] = v
|
|
|
+ } else if val != v {
|
|
|
+ t.tokens[key] = v
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func (t *MemoryStore) Remove(key string) {
|
|
|
t.lock.Lock()
|
|
|
defer t.lock.Unlock()
|