Skip to content

Commit

Permalink
Fix hashmap node is not deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhang Hongyu authored and maypok86 committed Aug 14, 2024
1 parent 3880b58 commit 43d7576
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions internal/core/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ func (c *Cache[K, V]) GetNode(key K) (node.Node[K, V], bool) {
}

if n.HasExpired() {
n.Die()
c.writeBuffer.Push(newExpiredTask(n))
// avoid duplicate push
deleted := c.hashmap.DeleteNode(n)
if deleted != nil {
n.Die()
c.writeBuffer.Push(newExpiredTask(n))
}
c.stats.IncMisses()
return nil, false
}
Expand Down

0 comments on commit 43d7576

Please sign in to comment.