use of javax.cache.configuration.MutableConfiguration in project wcomponents by BorderTech.
the class VelocityCacheImpl method getCache.
/**
* @return the cache instance
*/
protected synchronized Cache<Object, Resource> getCache() {
Cache<Object, Resource> cache = Caching.getCache(CACHE_NAME, Object.class, Resource.class);
if (cache == null) {
final CacheManager mgr = Caching.getCachingProvider().getCacheManager();
MutableConfiguration<Object, Resource> config = new MutableConfiguration<>();
config.setTypes(Object.class, Resource.class);
config.setExpiryPolicyFactory(AccessedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12)));
// Velocity template classes are not serializable so use by ref.
config.setStoreByValue(false);
cache = mgr.createCache(CACHE_NAME, config);
}
return cache;
}
use of javax.cache.configuration.MutableConfiguration in project Payara by payara.
the class PayaraCacheResolverFactory method getExceptionCacheResolver.
@Override
public CacheResolver getExceptionCacheResolver(CacheMethodDetails<CacheResult> cmd) {
CacheResult result = cmd.getCacheAnnotation();
String cacheName = result.exceptionCacheName();
Cache cache = cacheManager.getCache(cacheName);
if ((cache == null)) {
cache = cacheManager.createCache(cacheName, new MutableConfiguration<Object, Object>());
}
return new PayaraCacheResolver(cache);
}
use of javax.cache.configuration.MutableConfiguration in project cache2k by cache2k.
the class CacheManagerTest method create_cache2k_config_key_type_mismatch.
@Test(expected = IllegalArgumentException.class)
public void create_cache2k_config_key_type_mismatch() {
CachingProvider p = Caching.getCachingProvider();
CacheManager cm = p.getCacheManager();
MutableConfiguration cfg = ExtendedMutableConfiguration.of(new Cache2kBuilder<Long, Double>() {
});
Cache<Integer, Double> cache = cm.createCache("aCache", cfg.setTypes(Integer.class, Double.class));
cache.close();
}
use of javax.cache.configuration.MutableConfiguration in project tutorials by eugenp.
the class CacheLoaderTest method setup.
@Before
public void setup() {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<Integer, String> config = new MutableConfiguration<Integer, String>().setReadThrough(true).setCacheLoaderFactory(new FactoryBuilder.SingletonFactory<>(new SimpleCacheLoader()));
this.cache = cacheManager.createCache("SimpleCache", config);
}
use of javax.cache.configuration.MutableConfiguration in project tutorials by eugenp.
the class JCacheIntegrationTest method instantiateCache.
@Test
public void instantiateCache() {
CachingProvider cachingProvider = Caching.getCachingProvider();
CacheManager cacheManager = cachingProvider.getCacheManager();
MutableConfiguration<String, String> config = new MutableConfiguration<>();
Cache<String, String> cache = cacheManager.createCache("simpleCache", config);
cache.put("key1", "value1");
cache.put("key2", "value2");
assertEquals("value1", cache.get("key1"));
assertEquals("value2", cache.get("key2"));
cacheManager.close();
}
Aggregations