Take the 2-minute tour ×

I currently have a distributed cache using EHCache via RMI that works just fine. I was wondering if you can include persistence with the caches to create a distributed, persistent cache.

Alongside this, if the cache was persistent, would it load from the file store, then bootstrap from the cache cluster? Basically, what I want is:

  • Cache starts
  • Cache loads persistent objects from the file store
  • Cache joins the distruted cluster and bootstraps as normal

The usecase behind this is having 2 identical components running on independent machines, distributing the cache to avoid losing data in the event that one of the components fails. The persistence would guard against losing all data on the rare occasion that both components fail.

Would moving to another distribution method (such as Terracotta) support this?

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

I would take a look at the write-through caching options in EHCache. As described in the link, combining a read-through and write-behind cache will provide persistence to a user-defined data store.

What Terracotta gives you is consistency (so you don't have to worry about resolving conflicts among cluster members). You have the option of defining an interface to your own store (through CacheLoader and CacheWriter or just letting Terracotta persist your data, but I have received mixed signals from Terracotta and documentation on whether TC is appropriate for a system-of-record. If your data is transient and can be blown away at any time (like for web sessions) it might be OK.

share|improve this answer
Also to support the use-case you have described, you would need a third component, the user store (or a Terracotta cluster). EHCache does not support key-value backups AFAIK, while something like Hazelcast or Cassandra does rely on peers to redundantly store keys. –  sehugg Apr 30 '10 at 1:28
add comment

Adding bootstrapCacheLoaderFactory element along with cacheEventListenerFactory to the Cache(which which needs to bootstrapped from other nodes when it is down & replicates with other nodes if that node got any updates)

memoryStoreEvictionPolicy="LFU" diskPersistent="true"
timeToLiveSeconds="86400" maxElementsOnDisk="1000">

share|improve this answer
add comment

Your Answer


