Call onEvicted on flush
This commit is contained in:
parent
46f4078530
commit
79f2efb155
7
cache.go
7
cache.go
|
@ -1064,7 +1064,12 @@ func (c *cache) ItemCount() int {
|
||||||
// Delete all items from the cache.
|
// Delete all items from the cache.
|
||||||
func (c *cache) Flush() {
|
func (c *cache) Flush() {
|
||||||
c.mu.Lock()
|
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()
|
c.mu.Unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue