Reputation: 1489
we are using web-ehcache's net.sf.ehcache.constructs.web.filter.SimplePageCachingFilter, that configured by xml, to cache page where is JSON message, but this message can be changed by administrator. How to invalidate cache when administrator changes changes the JSON message?
Upvotes: 2
Views: 5487
Reputation: 1489
I figured out how to make it:
CacheManager.getInstance().getEhcache("CacheName").removeAll();
It gets singletone CacheManager, then gets Ehcache depending on name of cache, then removes elements.
In next request to that cached page, filter looks for Ehcache, finds, but without elementx and UPDATES elements!
Upvotes: 3
Reputation: 31903
I solve this by setting a time to live to 5 minutes:
<cache name="SimplePageCachingFilter"
maxElementsInMemory="100"
eternal="false"
timeToIdleSeconds="300"
timeToLiveSeconds="300"
overflowToDisk="true" />
Upvotes: 0