-
Notifications
You must be signed in to change notification settings - Fork 18
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
Why remove_expired
is not a public function?
#18
Comments
I guess this question is why would you want to clean it out? |
To make expired entries actually expire and free up resources (e.g. file descriptors). If you just don't touch |
I've resisted adding one because if a program relies on cleaning up resources by manually calling remove_expire() they either have too long cache times or intialized the cache with too high of a capacity. Manually going in and calling remove_expired() will help delay the potential resource exhaustion issue but doesn't remove it. V's that impl Drop make a better case for prematurely purging the cache though. Mind if I think about this one a bit more? |
Or sometimes idles and not uses the cache for prolonged periods of time. If cached entries are heavy (refers to a lof of memory, contains sockets, etc.), it can be problematic even with low times and low capacity. |
It'd be essential to make both In my case I need to measure current number of unexpired items; every new added item has the same TTL, so it's okay to call Can we make |
let _ = the_cache.iter()
is obvious workaround, but less readable and maintainable.Removing expired elements can be significant if their destructors do something, so that function may be called periodically on timer.
The text was updated successfully, but these errors were encountered: