Skip to content
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

Ability to expire entries on map access instead of in scheduled executor #61

Open
qualidafial opened this issue Feb 28, 2019 · 3 comments

Comments

@qualidafial
Copy link

See jdbi/jdbi#1453 for reference.

In JEE container environments like Tomcat or Wildfly, one needs to design applications for so that app-specific threads are stopped and classes may be unloaded, so that everything from the old .war can be freed when a new .war is deployed. ExpiringMap's use of static ScheduledExecutorService to expire entries, and ThreadPoolExecutor to notify expiration listeners are correctly logged as a thread leak.

In order to facilitate class unloading, it would be nice if we could configure our expiring maps to perform expiration and listener notification on the calling thread, whenever the map is accessed.

@jhalterman
Copy link
Owner

This seems worth doing, but I'm not available atm. I'd be happy to take a PR for this though.

We could make the expirer (threadpool) configurable in the builder, where if one is supplied then the static EXPIRER doesn't need to be constructed. We can then have a member var inside the ExpiringMap that either points to the user provided expirer or the static one. Similar with expiration.

@qualidafial
Copy link
Author

In the intervening months since reporting this issue, we have sadly found it necessary to remove expiringmap from Jdbi, in favor of our own naive caching solution. It is unlikely any of us will be able to devote the time for a PR.

Thank you for the follow up.

@jhalterman
Copy link
Owner

jhalterman commented Jul 29, 2019

No worries @qualidafial - hope it's working well for you 👍(random aside, I've used JDBI a lot in the past and really enjoy it).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants