mailgun / groupcache

Clone of golang/groupcache with TTL and Item Removal support
Apache License 2.0
484 stars 72 forks source link

Fix LRU to correctly evict cache items when replaced #52

Closed mattharr013 closed 1 year ago

mattharr013 commented 1 year ago

Currently when group.Set is called, if the key already exists in a cache instance, then nbytes is not updated correctly since OnEvicted is not called.

This means the cache slow leaks memory eventually being unable to cache any items.

To fix this, this PR updates the lru cache to call OnEvicted when replacing the value of an existing key.

matino commented 1 year ago

@thrawn01 is there any chance that this can be released?