isaacs / node-lru-cache

A fast cache that automatically deletes the least recently used items
http://isaacs.github.io/node-lru-cache/
ISC License
5.38k stars 353 forks source link

v7: disposal #188

Closed isaacs closed 2 years ago

isaacs commented 2 years ago

Dispose function is called when the entry is removed from the cache, for any reason, and no longer reachable.

That does mean that calling cache.set(key, value) with a duplicate key will dispose the old value, even if it is the same as the new value. There is no "noDisposeOnSet" option.

Old values will be disposed when they are no longer reachable by both the old and new, so if it's still in the old cache, and you overwrite it, no disposal until the next swap.