Skip to content

Commit

Permalink
Add a helper method to set eviction function after construction
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <[email protected]>
  • Loading branch information
dims committed Nov 2, 2024
1 parent 49e7df5 commit 8c2389e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lru/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func NewWithEvictionFunc(size int, f EvictionFunc) *Cache {
return c
}

// SetEvictionFunc updates the eviction func
func (c *Cache) SetEvictionFunc(f EvictionFunc) {
c.cache.OnEvicted = f
}

// Add adds a value to the cache.
func (c *Cache) Add(key Key, value interface{}) {
c.lock.Lock()
Expand Down

0 comments on commit 8c2389e

Please sign in to comment.