Actual cache size can go to double the maxSize
adityapatadia opened this issue · 5 comments
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 has been rewarded.
Sponsors (Total: $60.00)
- issuehunt ($60.00)
Tips
- Checkout the Issuehunt explorer to discover more funded issues.
- Need some help from other developers? Add your repositories on IssueHunt to raise funds.
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?
@pythonmobile Read the explanation of the algorithm: https://github.com/dominictarr/hashlru#algorithm
@IssueHunt has funded $60.00 to this issue.
- Submit pull request via IssueHunt to receive this reward.
- Want to contribute? Chip in to this issue via IssueHunt.
- Checkout the IssueHunt Issue Explorer to see more funded issues.
- Need help from developers? Add your repository on IssueHunt to raise funds.
@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