BigMemory 4.3.8 | Product Documentation | BigMemory Max Configuration Guide | Configuring Fast Restart (FRS) | Configuration Examples
 
Configuration Examples
This section presents possible disk usage configurations when using a standalone deployment.
Options for Crash Resilience
The following configuration provides fast restartability with fully consistent data persistence:
<ehcache>
<diskStore path="/path/to/store/data"/>
<cache>
<persistence strategy="localRestartable" synchronousWrites="true"/>
</cache>
</ehcache>
The following configuration provides fast restartability with eventually consistent data persistence:
<ehcache>
<diskStore path="/path/to/store/data"/>
<cache>
<persistence strategy="localRestartable" synchronousWrites="false"/>
</cache>
</ehcache>
Clustered Caches
For distributing BigMemory Max across a Terracotta Server Array (TSA), the persistence strategy in the ehcache.xml should be set to "distributed", and the <terracotta> sub-element must be present in the configuration.
<cache>
maxEntriesInCache="100000">
<persistence strategy="distributed"/>
<terracotta clustered="true" consistency="eventual" synchronousWrites="false"/>
</cache>
The attribute maxEntriesInCache configures the maximum number of entries in a distributed cache. (maxEntriesInCache is not required, but if it is not set, the default is unlimited.)
Note:
Restartability must be enabled in the TSA in order for clients to be restartable.
Temporary Disk Storage
The "localTempSwap" persistence strategy create a local disk tier for in-memory data during BigMemory operation. The disk storage is temporary and is cleared after a restart.
<ehcache>
<diskStore path="/auto/default/path"/>
<cache>
<persistence strategy="localTempSwap"/>
</cache>
</ehcache>
Note:
With the "localTempSwap" strategy, you can use maxEntriesLocalDisk or maxBytesLocalDisk at either the Cache or CacheManager level to control the size of the disk tier.
In-memory Only Cache
When the persistence strategy is "none", all cache stays in memory (with no overflow to disk nor persistence on disk).
<cache>
<persistence strategy="none"/>
</cache>
Programmatic Configuration Example
The following is an example of how to programmatically configure cache persistence on disk:
Configuration cacheManagerConfig = new Configuration()
.diskStore(new DiskStoreConfiguration()
.path("/path/to/store/data"));
CacheConfiguration cacheConfig = new CacheConfiguration()
.name("my-cache")
.maxBytesLocalHeap(16, MemoryUnit.MEGABYTES)
.maxBytesLocalOffHeap(256, MemoryUnit.MEGABYTES)
.persistence(new PersistenceConfiguration().strategy(Strategy.LOCALRESTARTABLE));
cacheManagerConfig.addCache(cacheConfig);
CacheManager cacheManager = new CacheManager(cacheManagerConfig);
Ehcache myCache = cacheManager.getEhcache("my-cache");