-
-
Notifications
You must be signed in to change notification settings - Fork 76
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
[question] The lazyness of expiration #125
Comments
Hi. Thank you for using Moka.
As for 1, please let me know whether you are okay with the current delay or not. We could make the delay configurable per cache. As for 2, let me explore some ideas to resolve/mitigate the GC issue. |
Thanks for your reply, I think preserving an evicted connection for less than 3s is ok (after all the connection pool is just a toy project), and it seems hardly occur. And I would like to take a deeper look into |
Congratulations! 🎉
I wish I had more time to write design docs, so all you can read now are:
Moka's design is heavily inspired by the Caffeine library for Java. So you can learn the base design from Caffeine's publications: https://github.com/ben-manes/caffeine#in-the-news I started to develop Moka because I needed a concurrent cache for the storage layer of a NoSQL database (as my hobby project) and found there was no such cache library in Rust that would meet my needs. I thought I will finish implementing Moka in a couple of months so I can go back to my original project quickly. I never thought it would take some years (but I am enjoying). |
This one could be something we are actually noticing. Our cache entries are quite large and not that many so having about ~100 of them hanging around might look like a memory leak to us. Is there any way to mitigate this? |
Sorry for not getting back to you sooner. I wonder if we could mitigate it by using the https://docs.rs/crossbeam-epoch/0.9.9/crossbeam_epoch/struct.Guard.html#method.flush
We use some "deferred functions" to drop entries removed from cache. Let me try it in next few days. I will measure performance impacts for both memory usage and speed. |
No worries, thanks for getting back to me. Thank you for looking into it! Sounds like an approach that could work. |
As for the |
Sorry, it took longer than I thought. But I have published Moka v0.9.3 to crates.io. |
Hello maintainer, I'd like to know whether the expiration of cache is
lazy
oractive
.By
lazy
I mean not until getting on the expired entry or other scenarios that have to remove it, the entry will be preserved in the cache;Corresponsively by
active
I mean if the entry outlived its TTL or IDLE, the entry will be instantly evicted.I've also used this crate to build a server-side connection pool, and I hope any outlived connections should be dropped immediately. Nothing about this was in the
README
, but byinvalidate_entries_if()
method I guess this cache should belazy
?The text was updated successfully, but these errors were encountered: