Call onEvicted on flush

This commit is contained in:
codesoap 2022-04-25 20:57:23 +02:00
parent 46f4078530
commit 79f2efb155
1 changed files with 6 additions and 1 deletions

View File

@ -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()
}