Vishal Vishal - 14 days ago 28
Java Question

How to clear ehcache without server restart

Though I guess its highly unlikely - but is there any way to clear the ehcache without restarting the server?
I need to clear the cache for some testing - I cannot change the code and cannot afford to restart server at multiple times.

PS: I am using apache-tomcat-5.5.25
Please let me know.
Thanks,
psvm

Answer

Do you expose Ehcache via JMX? Then you could clear the cache using JMX operations by using a tool like e.g. jvisualvm. Look for MBeans like net.sf.ehcache.CacheManager which provide a clearAll() operation.