Skip to content

Commit

Permalink
Merge pull request #319 from dims/add-lock-unlock-in-SetEvictionFunc
Browse files Browse the repository at this point in the history
Add lock/unlock in SetEvictionFunc
  • Loading branch information
k8s-ci-robot authored Nov 4, 2024
2 parents 3ea5e8c + 7a270de commit 6fe5fd8
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lru/lru.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
Expand Down

0 comments on commit 6fe5fd8

Please sign in to comment.