Comments (8)
@hypirion Thanks for feedback!
I understand your opinion, but I have one concern. That is the data will remain on memory unless the next Get method is called.
I'm hoping this can be solved, so please, give me some ideas!
Oh, right. https://github.com/patrickmn/go-cache uses one janitor goroutine per cache, which at some user-specified interval removes all expired items from the cache:
There is a bit more overhead when getting values, as you have to check whether they have expired or not. Perhaps one of those things prevent this from being doable, as I haven't looked too closely at the performance implications of this.
And true, as outlined and tested in https://tpaschalis.github.io/goroutines-size/, the goroutine stack size is minimum 2kb, but could be more -- although I don't think the cleanup routines would go much beyond that.
I'd happy to take a look and make a PR if I find a workable solution that doesn't add too much complexity. If I were to do that I'd still fall back on the original implementation with goroutines though, for backwards compatibility/behaviour.
from go-generics-cache.
I find myself in the same situation. Thousands of ExpirationWatcher goroutines.
I think the idea mentioned above is the right direction: one routine taking care of collecting all expired items.
from go-generics-cache.
@hypirion Thanks for feedback!
I understand your opinion, but I have one concern. That is the data will remain on memory unless the next Get method is called.
I'm hoping this can be solved, so please, give me some ideas!
Thanks
from go-generics-cache.
And, I don't believe each goroutine size is 2kb. The size meaning for initial stack size.
See https://tpaschalis.github.io/goroutines-size/
from go-generics-cache.
@hypirion Thanks. I'm looking forward to the PR you create!
If you have no time, I can make PR for it. So please let me know.
from go-generics-cache.
improved, pls check the code
from go-generics-cache.
I've just published the latest version. Thank you for your contributions!
https://github.com/Code-Hex/go-generics-cache/releases/tag/v1.1.0
from go-generics-cache.
Thanks for the contribution here!
from go-generics-cache.
Related Issues (8)
- Maybe change containers/list to implementations on generics HOT 5
- Clock policy: Not show all the page with sequential access pattern HOT 1
- Can a read-write lock be used in the cache instead of a mutex? HOT 1
- fatal error: concurrent map read and map write HOT 1
- Panic when deleting expired items HOT 3
- LFU: Allow setting the frequency and update the heap HOT 2
- Panic when delete expired items. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from go-generics-cache.