diff --git a/cache/vars.go b/cache/vars.go index 3f42b9f..39ca2d4 100644 --- a/cache/vars.go +++ b/cache/vars.go @@ -156,7 +156,10 @@ type VarMemoryCache[T any] struct { } func (c *VarMemoryCache[T]) ClearExpired(ctx context.Context) { - c.Flush(ctx) + _, ok := c.Get(ctx) + if !ok { + c.Flush(ctx) + } } func NewVarMemoryCache[T any](expireTime func() time.Duration) *VarMemoryCache[T] {