We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3ea5e8c commit 7a270deCopy full SHA for 7a270de
lru/lru.go
@@ -47,6 +47,8 @@ func NewWithEvictionFunc(size int, f EvictionFunc) *Cache {
47
48
// SetEvictionFunc updates the eviction func
49
func (c *Cache) SetEvictionFunc(f EvictionFunc) error {
50
+ c.lock.Lock()
51
+ defer c.lock.Unlock()
52
if c.cache.OnEvicted != nil {
53
return fmt.Errorf("lru cache eviction function is already set")
54
}
0 commit comments