Skip to content

Instantly share code, notes, and snippets.

@mpellegrini
Created July 1, 2014 02:49
Show Gist options
  • Save mpellegrini/233c2318a5555e8e53ac to your computer and use it in GitHub Desktop.
Save mpellegrini/233c2318a5555e8e53ac to your computer and use it in GitHub Desktop.
Creating Ehcache Programmatically
// Create a configuration
Configuration configuration = new Configuration();
//Create a CacheManager using defaults
CacheManager manager = CacheManager.create(configuration);
//Create a Cache specifying its configuration.
Cache testCache = new Cache(
new CacheConfiguration("test", maxElements)
.memoryStoreEvictionPolicy(MemoryStoreEvictionPolicy.LFU)
.overflowToDisk(true)
.eternal(false)
.timeToLiveSeconds(60)
.timeToIdleSeconds(30)
.diskPersistent(false)
.diskExpiryThreadIntervalSeconds(0));
manager.addCache(cache);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment