Configure a nonstop cache programmatically in Ehcache

Here’s how to configure programmatically a nonstop cache in Ehcache (this one is clustered, connecting to terracotta running on localhost):

import net.sf.ehcache.config.*;

Configuration configuration = new Configuration()
   .terracotta(new TerracottaClientConfiguration().url("localhost:9510"))
   .defaultCache(new CacheConfiguration("defaultCache", 10000))
      new CacheConfiguration("nonstopCache", 10000)
      .terracotta(new TerracottaConfiguration().consistency(TerracottaConfiguration.Consistency.STRONG)
      .nonstop(new NonstopConfiguration().enabled(true).timeoutMillis(4000)
      .timeoutBehavior(new TimeoutBehaviorConfiguration()
CacheManager cacheManager = new CacheManager(configuration);

4 thoughts on “Configure a nonstop cache programmatically in Ehcache

    1. When using a clustered cache, you have a number of applications sharing the cache content in a cluster.
      If your application is temporarily disconnected from the cluster (for instance because of a network problem), you can set your cache as nonstop, meaning that it will continue working according to the nonstop behaviour you define, instead of being blocked.

      1. thanks for your sufficient explanation.
        but I have misunderstanding the point of ; what’s the “timeoutMillis” for? is that for making a time for blocking specific running operations in the cache ? .. and what’s the difference between it and ” timeToLiveSeconds”?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s