Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxCacheSize option #63

Closed
jbass86 opened this issue Jun 7, 2016 · 8 comments
Closed

maxCacheSize option #63

jbass86 opened this issue Jun 7, 2016 · 8 comments

Comments

@jbass86
Copy link

jbass86 commented Jun 7, 2016

I have been looking into a caching solution for a node project of mine and I think this library looks very useful!. One thing I think could be a great addition though is to have a maximum cache size (perhaps either number of entries or memory size) which when exceeded will cause the check routine to evict the oldest entries from the cache to bring it back down to this size.

This of course would be entirely optional and if not set the cache would operate exactly as it does now.

@mpneuried mpneuried self-assigned this Jun 20, 2016
@mpneuried
Copy link
Contributor

Thanks!
This is a nice idea.
I add it to the TODO list and will have a look at it until there is some time ;-)

@Marcelo-Petrucelli
Copy link

This would be GREAT!
Up.

@erdii
Copy link
Member

erdii commented Aug 22, 2019

@daluf will take care of this

daluf added a commit to daluf/nodecache that referenced this issue Aug 23, 2019
daluf added a commit to daluf/nodecache that referenced this issue Aug 23, 2019
@erdii
Copy link
Member

erdii commented Aug 23, 2019

This has landed in pr #141
Will be part of v5.0

@erdii erdii closed this as completed Aug 23, 2019
@sarathkcm
Copy link

I think instead of throwing error, it should remove the oldest entry in cache and accommodate the new entry. Having a fixed size for cache is to limit the memory usage, and cache being full isn't really an error scenario.

Just started using this library in a project, and saw this flag in the docs.

@erdii
Copy link
Member

erdii commented Jan 8, 2020

We currently regard sophisticated expiry logic like that as to big for that project :(

@yavulan
Copy link

yavulan commented Mar 10, 2021

@erdii You used "currently" in your answer around a year ago, so I am asking again about #63 (comment) :)

@8bitjoey
Copy link

up. Evicting oldest key is the best option. Or at least allow us to catch such error using event handling so that we can do that ourselves

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants