diff --git a/common/cache/lrucache.go b/common/cache/lrucache.go index 37fa26b..a8912e8 100644 --- a/common/cache/lrucache.go +++ b/common/cache/lrucache.go @@ -258,6 +258,14 @@ func (c *LruCache[K, V]) Delete(key K) { c.mu.Unlock() } +func (c *LruCache[K, V]) Clear() { + c.mu.Lock() + defer c.mu.Unlock() + for element := c.lru.Front(); element != nil; element = element.Next() { + c.deleteElement(element) + } +} + func (c *LruCache[K, V]) maybeDeleteOldest() { if !c.staleReturn && c.maxAge > 0 { now := time.Now().Unix()