Skip to content

Commit

Permalink
Cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
mgnsk committed Feb 10, 2021
1 parent 21824fc commit f8e3547
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ func (c *Cache) Evict(key interface{}) {
if !loaded {
return
}
r := value.(*record)
c.wg.Add(1)
go func() {
defer c.wg.Done()
r := value.(*record)
value, loaded := r.LoadAndReset()
if !loaded {
// An inactive record which had a concurrent Fetch and failed.
Expand Down Expand Up @@ -236,15 +236,15 @@ func (c *Cache) Close() error {
}

func (c *Cache) deleteIfEquals(key interface{}, r *record) {
new, loaded := c.records.Load(key)
old, loaded := c.records.Load(key)
if !loaded {
return
}
if new.(*record) != r {
if old.(*record) != r {
return
}
new, loaded = c.records.LoadAndDelete(key)
if loaded && new.(*record) != r {
old, loaded = c.records.LoadAndDelete(key)
if loaded && old.(*record) != r {
panic("evcache: inconsistent map state")
}
}
Expand Down

0 comments on commit f8e3547

Please sign in to comment.