Answer the question
In order to leave comments, you need to log in
Spring @Cacheable - remove(clear) all cache?
Tell me, is there any method to delete the entire cache?
I saw that you can call the CacheManager to load all the names of the cache into it and then delete one by one, how to implement it? I don't know how to get cache from ehcache.xml.
Let's say there are 2 caches defined, how to delete them with one call?
Cache by name can be deleted @CacheEvict(value = "books", allEntries=true)
Here are the config settings:
<!-- cache setup -->
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean" p:config-location="classpath:ehcache.xml" />
<bean id="cacheManager" class="org.springframework.cache.ehcache.EhCacheCacheManager" p:cacheManager-ref="ehcache" />
Answer the question
In order to leave comments, you need to log in
Get a bean with id=cacheManager and do whatever you want - EhCacheCacheManager provides an interface to work with the cache by name.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question