fix var memory cache bug

This commit is contained in:
xing 2023-12-17 19:34:04 +08:00
parent f257a966e6
commit 57d345e445

3
cache/vars.go vendored
View File

@ -156,7 +156,10 @@ type VarMemoryCache[T any] struct {
} }
func (c *VarMemoryCache[T]) ClearExpired(ctx context.Context) { func (c *VarMemoryCache[T]) ClearExpired(ctx context.Context) {
_, ok := c.Get(ctx)
if !ok {
c.Flush(ctx) c.Flush(ctx)
}
} }
func NewVarMemoryCache[T any](expireTime func() time.Duration) *VarMemoryCache[T] { func NewVarMemoryCache[T any](expireTime func() time.Duration) *VarMemoryCache[T] {