-
I create temporary caches dynamically for each request. When a request completes, the cache items are evicted, leaving the cache instances empty but still in memory. How can I dispose of these cache instances entirely? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I'm not sure what you mean. The cache does not maintain any global state, e.g. we do not directly offer a 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 opinionated, Caffeine is merely a data structure library and not an application framework. Can you explain more about what you are doing? You might need to ask on a different forum like the application framework's as more their world than ours. |
Beta Was this translation helpful? Give feedback.
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 ajava.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…