-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Expiration triggered by cache.asMap iterators doesn't notify RemovalListener #487
Comments
Would calling Note that the listener invocation is delegated to the If you want resources to be closed more promptly during normal operations, then consider using Does that help? |
Thanks for the VERY prompt response! Good hints! It helps a lot. I'd just thought about replacing cleanUp with invalidataAll. And now I tested it. Seems that it will do the work - RemovalListener gets explicit and expired events on invalidateAll - so I hope such cleanup will cover all values. Anyway, it seems as a work around - don't you feel it will be more consistent (and matching user expectations) if expiration triggered by asMap iterators are reported to RemovalListener? |
I don't have a strong opinion either way and it seemed harmless to add, so done. |
I have an 'expire after access' cache (Caffeine version: 2.8.8) with values that I need to close (grpc managed channels). I have two close points:
however, asMap iteration doesn't return expired values (which, seeing some posted issues, seems expected) , but the problem is that RemovalListener doesn't get notifications for expired entries.
There is a simple code that demonstrates this:
I found out that cache.cleanUp() just before cache asMap() will trigger expiration that notifies RemovalListener, but this just could mitigate the issue (will notify for some expirations). However, if an entry expire between cleanUp and asMap - this entry will still be lost.
I believe that triggered by cache.asMap iteration expirations shall notify RemovalListener.
Is there a way to implement that value cleanup correctly with current Caffeine release?
The text was updated successfully, but these errors were encountered: