sindresorhus/quick-lru

Actual cache size can go to double the maxSize

adityapatadia opened this issue · 5 comments

Issuehunt badges

When the main cache is filled, items are moved to oldCache. Now, it starts getting items from oldCache and puts in cache when they are accessed. Here, the items still remain in oldCache so in some cases, the memory use will be double where oldCache is full and the new cache has maxSize - 1 items.

Can the cache be deleted from oldCache after it's moved to current cache?
https://github.com/sindresorhus/quick-lru/blob/master/index.js#L32

IssueHunt Summary

adityapatadia adityapatadia has been rewarded.

Sponsors (Total: $60.00)

Tips

Can the cache be deleted from oldCache after it's moved to current cache?

I think so, yes.

The implementation does not look like a LRU cache? It seems when one inserts a new element, and if the cache is full, instead of evicting the least recently used element, this code splits the cache into old/new cache? Am I missing something?

@IssueHunt has funded $60.00 to this issue.


@sindresorhus has rewarded $54.00 to @adityapatadia. See it on IssueHunt

  • 💰 Total deposit: $60.00
  • 🎉 Repository reward(0%): $0.00
  • 🔧 Service fee(10%): $6.00