Closed trung closed 3 weeks ago
Good point, I'll add a removeCache(String name)
method on CaffeineCacheManager
for 6.1.15.
Please also add removeCache(String name)
for ConcurrentMapCacheManager
as well. I'm not using it but I do see it has similar need.
@jhoeller is instead @Bean @RequestScoped CacheManager
the intended idiom?
(that was my best guess when asked in https://github.com/ben-manes/caffeine/discussions/1790)
@ben-manes that would indeed work but I can also see the need for runtime removal of certain caches in a shared CacheManager scenario. As long as the cache names are distinct enough, I can see that working for short-lived request caches as well.
I use
CaffeineCacheManager
and 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.CaffeineCacheManager
has an internalcacheMap
which keeps growing as caches are dynamically created.Is there away to remove/deregister the empty cache instances from
cacheMap
?