Example 2: Programmatic Configuration
To configure
BigMemory Max programmatically, use the
Ehcache fluent configuration API.
Configuration managerConfiguration = new Configuration()
.name("bigmemory-config")
.cache(new CacheConfiguration()
.name("BigMemory")
.maxBytesLocalHeap(512, MemoryUnit.MEGABYTES)
.maxBytesLocalOffHeap(1, MemoryUnit.GIGABYTES)
.copyOnRead(true)
.statistics(true)
.eternal(true)
);
CacheManager manager = CacheManager.create(managerConfiguration);
try {
Cache bigMemory = manager.getCache("BigMemory");
// now do stuff with it...
} finally {
if (manager != null) manager.shutdown();
}