I'm using Ehcache
to cache the results of an expensive service call within a web application.
I want the cache to persist across JVM restarts.
I configured a 2-tier ehcache with heap
and disk
. Unfortunately Ehcache only saves the cache to disk when PersistentCacheManager.close()
is called.
How can I get the persistence to work properly? Am I supposed to periodically close and reopen the cache? Should I be looking at something other than ehcache for this?
I would recommend you to use at Terracotta cluster deployment (it's open source too), next to your web application JVMs.
You would then configure, on your web applications, 3 tiers : heap, offheap and clustered
The Terracotta server deployment would be 1 Active, 1 Passive - so that when you have a failure or a predicated maintenance on 1 server, the other still serves all the clients.
The benefits of using the open source clustered tier, versus the open source disk tier, is that in case of failure (web application container failure, terracotta server failure), your data is still intact, thanks to the redundancy of your setup.