Skip to content

Commit 8c2389e

Browse files
committed
Add a helper method to set eviction function after construction
Signed-off-by: Davanum Srinivas <[email protected]>
1 parent 49e7df5 commit 8c2389e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lru/lru.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ func NewWithEvictionFunc(size int, f EvictionFunc) *Cache {
4444
return c
4545
}
4646

47+
// SetEvictionFunc updates the eviction func
48+
func (c *Cache) SetEvictionFunc(f EvictionFunc) {
49+
c.cache.OnEvicted = f
50+
}
51+
4752
// Add adds a value to the cache.
4853
func (c *Cache) Add(key Key, value interface{}) {
4954
c.lock.Lock()

0 commit comments

Comments
 (0)