I have an ehcache setup, that works just fine, except that the persistent diskstore data is removed everytime I restart my application/server (Spring application on TcServer/Tomcat). The whole point of using the persistent diskstore was to be able to persist the cache in spite of application restarts.
Here is my ehcache.xml
<?xml version="1.0" encoding="UTF-8"?><ehcache><diskStore path="java.io.tmpdir/ehcache"/><cache name="clusterCache"
maxElementsInMemory="1"
maxElementsOnDisk="50"
eternal="true"
overflowToDisk="true"
diskPersistent="true"
memoryStoreEvictionPolicy="LFU"/></ehcache>
Any ideas why this is happening?
As the documentation notes, Ehcache doesn't write the index file that it looks for to restore from the disk unless the cache is properly shutdown, either via a VM shutdown hook or (since this is in a servlet container) the servlet context listener it provides. See the Ehcache documentation on shutting down for details, though it just means adding the below to your web.xml:
<listener>
<listener-class>net.sf.ehcache.constructs.web.ShutdownListener</listener-class>
</listener>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With