Closed mkomaiha closed 2 years ago
Ahhhh, yeah, good bug, thanks for tracking the root cause so clearly.
clear()
should call dispose on all items, not just those iterated over by rindexes
.
Really, it should be for (const index of this.rindexes({ allowStale: true }))
and rindexes
and indexes
should respect that flag if provided.
Clear function gets called in purgeStale when the size of the cache is 1 and the clear dispose only loops rIndexes when disposing so stale items are not disposed. How can I handle the clean up of the last item in the cache if it is stale?
https://github.com/isaacs/node-lru-cache/blob/da932f7daaa4b013d917dd215ba18253cef56c33/index.js#L543-L553