Clone a new cache from an existing configuration
We can also use default cache configuration (or any other cache configuration) as a starting point for creation of a new cache. For example, lets say that my-config-file.xml specifies a replicated cache as a default and that we want to create a distributed cache with a specific L1 lifespan while at the same time retaining all other aspects of a default cache in my-config-file.xml. Therefore, we start with a clone instance of default Configuration object and then we set cache mode and L1 lifespan accordingly. As a final step we define/register this configuration with a manager. Â EmbeddedCacheManager manager = new DefaultCacheManager("my-config-file.xml"); Configuration c = manager.getDefaultConfiguration().clone(); c.setCacheMode(CacheMode.DIST_SYNC); c.setL1Lifespan(60000L); Â Â Â Â Â String newCacheName = "distributedWithL1"; manager.defineConfiguration(newCacheName, c); Cache cache = manager.getCache(newCacheName);