Skip to content

Instantly share code, notes, and snippets.

@noelyahan
Last active August 29, 2015 14:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noelyahan/7183280050e400b24c1e to your computer and use it in GitHub Desktop.
Save noelyahan/7183280050e400b24c1e to your computer and use it in GitHub Desktop.
CacheManager cacheManager = Caching.getCachingProvider().getCacheManager();
//CacheManager cacheManager = Caching.getCachingProvider().getCacheManager(new URI("sampleCacheManager"));
String cacheName = "cacheXXX";
cache = cacheManager.createCache(cacheName, new MutableConfiguration<K, V>()
.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, cacheTimeout)))
.setExpiryPolicyFactory(ModifiedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, cacheTimeout)))
.setStoreByValue(false));
int value = 9876;
cache.put(key, value);
assertEquals(cache.get(key).intValue(), value);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment