Forráskód Böngészése

feat: add Refresh

2637309949@qq.com 5 éve
szülő
commit
e43b155b2d
1 módosított fájl, 3 hozzáadás és 3 törlés
  1. 3 3
      utils/token_store.go

+ 3 - 3
utils/token_store.go

@@ -15,7 +15,7 @@ type TokenStore interface {
 	Get(string) *entitys.Token
 	Set(string, *entitys.Token)
 	Remove(key string)
-	Refresh(key string)
+	Refresh(key string) *entitys.Token
 }
 
 type MemoryStore struct {
@@ -65,14 +65,14 @@ func (t *MemoryStore) Remove(key string) {
 	delete(t.tokens, key)
 }
 
-func (t *MemoryStore) Refresh(key string) {
+func (t *MemoryStore) Refresh(key string) *entitys.Token {
 	t.lock.Lock()
 	defer t.lock.Unlock()
-
 	val, ok := t.tokens[key]
 	if ok {
 		val.TimeStamp = uint64(time.Now().UnixNano())
 	}
+	return val
 }
 
 func (t *MemoryStore) startTokenCheckProcess() {