Skip to content

How can I dispose of these cache instances entirely? #1790

Answered by ben-manes
trung asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure what you mean. The cache does not maintain any global state, e.g. we do not directly offer a CacheManager. Caffeine is just like a java.util.ConcurrentHashMap except with a bounding policy, so once there are no more references then the GC will collect. If you create an instance per request then when the request completes, the cache should go away along with any other request-scoped state.

If you use a higher level abstraction, like a CacheManager, which is assuming singletons that are long-lived and reused, then you would need to unregister the instance. That might be more of a Spring, JCache, etc concept which has expectations of how you use their frameworks. We are not so o…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@trung
Comment options

@ben-manes
Comment options

@trung
Comment options

Answer selected by ben-manes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants