Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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">

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top