Skip to content

Commit

Permalink
impl Purge func
Browse files Browse the repository at this point in the history
  • Loading branch information
knbr13 committed May 29, 2024
1 parent 60b97a9 commit 4c929f4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lfu_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,14 @@ func (l *LFUCache[K, V]) Keys() []K {
return keys
}

func (l *LFUCache[K, V]) Purge() {
l.mu.Lock()
defer l.mu.Unlock()

l.m = make(map[K]*list.Element)
l.evictionList.Init()
}

func (l *LFUCache[K, V]) Count() int {
l.mu.RLock()
defer l.mu.RUnlock()
Expand Down

0 comments on commit 4c929f4

Please sign in to comment.