diff --git a/lru/lru.go b/lru/lru.go index f0b67462..40c22ece 100644 --- a/lru/lru.go +++ b/lru/lru.go @@ -47,6 +47,8 @@ func NewWithEvictionFunc(size int, f EvictionFunc) *Cache { // SetEvictionFunc updates the eviction func func (c *Cache) SetEvictionFunc(f EvictionFunc) error { + c.lock.Lock() + defer c.lock.Unlock() if c.cache.OnEvicted != nil { return fmt.Errorf("lru cache eviction function is already set") }