From 79f2efb155ffbde483009cfa2fb58de3dc066dda Mon Sep 17 00:00:00 2001 From: codesoap Date: Mon, 25 Apr 2022 20:57:23 +0200 Subject: [PATCH] Call onEvicted on flush --- cache.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cache.go b/cache.go index db88d2f..e198c11 100644 --- a/cache.go +++ b/cache.go @@ -1064,7 +1064,12 @@ func (c *cache) ItemCount() int { // Delete all items from the cache. func (c *cache) Flush() { c.mu.Lock() - c.items = map[string]Item{} + for k := range c.items { + v, evicted := c.delete(k) + if evicted { + c.onEvicted(k, v) + } + } c.mu.Unlock() }