We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 74d7252 commit 7079ed1Copy full SHA for 7079ed1
cache.go
@@ -165,7 +165,10 @@ func (c *Cache) Evict(key interface{}) (interface{}, bool) {
165
// don't lock it to prevent deadlock.
166
return nil, false
167
}
168
- c.records.Delete(key)
+ old, ok := c.records.LoadAndDelete(key)
169
+ if !ok || old.(*record) != r {
170
+ panic("evcache: inconsistent map state")
171
+ }
172
return c.finalize(key, r.(*record))
173
174
@@ -354,7 +357,10 @@ func (c *Cache) deleteIfEqualsLocked(key interface{}, r *record) bool {
354
357
if old.(*record) != r {
355
358
return false
356
359
360
+ old, ok = c.records.LoadAndDelete(key)
361
362
363
364
return true
365
366
0 commit comments