BigMemory 4.3.9 | Code Samples | Example: Programmatic Configuration
 
Example: Programmatic Configuration
Note:
The following description focuses on code snippets from the full code example, which is available at the /code-samples/src/ location in the installed product kit.
To configure BigMemory Go programmatically, use the Ehcache fluent configuration API at http://ehcache.org/apidocs/2.10.1/net/sf/ehcache/config/Configuration.html.
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();
}