-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
need to manually run_pending_tasks()
to trigger eviction_listener callback.
#349
Comments
Hi. It does not have to be Before v0.12.0, Moka had its own global thread pool to periodically run pending tasks. Some users did not like it, so we removed it. You will find more details here when pending tasks (internal maintenance tasks) will be executed: https://github.com/moka-rs/moka/blob/main/MIGRATION-GUIDE.md#the-maintenance-tasks
You can spawn a thread and make it to call |
aaah now I get it, thanks a lot, i would really appreciate if you add an example in the examples folder and point to it in the readme |
one more thing, could you please kindly think of a way to pass exact eviction_time? so maybe we could have two variants of eviction_listener functions, one could be executed without evection time like what it is now for the sake of backward compatibility, and another one could be executed with exact time that the eviction has really happened. in my eviction_listener i have to check if the eviction has happened after certain time or not, so having the exact eviction time could help me to have a more solid eviction_listener function. |
Is eviction_time impossible? |
Hi. I will not be able to work on moka for next few weeks because I am in a hospital now. #352. (I only have a smart phone now) eviction_time is possible but maybe not necessary(?) as it is guaranteed that the eviction listener should be called immediately after the eviction. Eviction is delayed until pending tasks are procecced, but once these tasks are processed and a cached entry is evicted, the eviction listener should be called immediately. So eviction_time will be a few nano/micro seconds before when the eviction listener is called. There will be one exception though. OS can preempt a thread at any time and it can cause some (a few milliseconds?) delay before calling eviction listener. If your application cannot tolerate this delay, eviction_time will be needed. The following doc was for v0.11.3. It explains how the immediate delivery mode worked in v0.11. moka v0.12 always uses the immediate mode, so the doc is valid for v0.12 except v0.12 does not have background eviction threads. |
😔 i hope you get well as soon as possible💚💚 |
for my case it's not super important. i was just looking at it as an idea for a possible future improvement 🙏 |
Hello,
in the end of my main() function i have this while loop:
it will wait 5 seconds for something and then after that it will print the content of the cache,
the problem is that if i don't invoke
run_pending_tasks()
theeviction_listener
would not be called,but i want the eviction_listener() to be called exactly at the time of eviction, not some time later,
can you please help me to understand what should i do?
The text was updated successfully, but these errors were encountered: