File size: 549 Bytes
7107f0b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
package lark
import (
"context"
"github.com/Xhofe/go-cache"
"time"
)
type TokenCache struct {
cache.ICache[string]
}
func (t *TokenCache) Set(_ context.Context, key string, value string, expireTime time.Duration) error {
t.ICache.Set(key, value, cache.WithEx[string](expireTime))
return nil
}
func (t *TokenCache) Get(_ context.Context, key string) (string, error) {
v, ok := t.ICache.Get(key)
if ok {
return v, nil
}
return "", nil
}
func newTokenCache() *TokenCache {
c := cache.NewMemCache[string]()
return &TokenCache{c}
}
|