Java examples for javax.cache:Cache
create Cache
// Copyright (C) YOYO Project Team. All rights reserved. import javax.cache.Cache; import javax.cache.CacheBuilder; import javax.cache.CacheManager; import javax.cache.Caching; import javax.cache.transaction.IsolationLevel; import javax.cache.transaction.Mode; public class Main{ public static void main(String[] argv) throws Exception{ String cacheName = "java2s.com"; System.out.println(createCache(cacheName)); }/*from ww w .j a va 2 s . c o m*/ private static final CacheManager MANAGER = Caching.getCacheManager(); public static <K, V> Cache<K, V> createCache(final String cacheName) { final CacheBuilder<K, V> builder = MANAGER .createCacheBuilder(cacheName); builder.setStoreByValue(true); builder.setStatisticsEnabled(true); return builder.build(); } }