Skip to content

Commit 6fe5fd8

Browse files
authored
Merge pull request #319 from dims/add-lock-unlock-in-SetEvictionFunc
Add lock/unlock in SetEvictionFunc
2 parents 3ea5e8c + 7a270de commit 6fe5fd8

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

lru/lru.go

+2
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ func NewWithEvictionFunc(size int, f EvictionFunc) *Cache {
4747

4848
// SetEvictionFunc updates the eviction func
4949
func (c *Cache) SetEvictionFunc(f EvictionFunc) error {
50+
c.lock.Lock()
51+
defer c.lock.Unlock()
5052
if c.cache.OnEvicted != nil {
5153
return fmt.Errorf("lru cache eviction function is already set")
5254
}

0 commit comments

Comments
 (0)