public static <K, V> Configuration<K, V> fromConfig(Config config) { MutableConfiguration<K, V> jcacheConfig = new MutableConfiguration<K, V>(); return new RedissonConfiguration<K, V>(config, jcacheConfig); }
public static <K, V> Configuration<K, V> fromConfig(Config config) { MutableConfiguration<K, V> jcacheConfig = new MutableConfiguration<K, V>(); return new RedissonConfiguration<K, V>(config, jcacheConfig); }
public static <K, V> Configuration<K, V> fromInstance(RedissonClient redisson) { MutableConfiguration<K, V> config = new MutableConfiguration<K, V>(); return fromInstance(redisson, config); }
public static <K, V> Configuration<K, V> fromInstance(RedissonClient redisson) { MutableConfiguration<K, V> config = new MutableConfiguration<K, V>(); return fromInstance(redisson, config); }
public CaffeineConfiguration() { delegate = new MutableConfiguration<>(); delegate.setStoreByValue(false); tickerFactory = SYSTEM_TICKER; executorFactory = COMMON_POOL; copierFactory = JAVA_COPIER; }
/** * Create a simple configuration that enable statistics via the JCache programmatic configuration API. * <p> * Within the configuration object that is provided by the JCache API standard, there is only a very limited set of * configuration options. The really relevant configuration options (like the size limit) must be set via a * configuration mechanism that is provided by the selected JCache implementation. */ private javax.cache.configuration.Configuration<Object, Object> cacheConfiguration() { return new MutableConfiguration<>().setStatisticsEnabled(true); }
public JCacheConfiguration(Configuration<K, V> configuration) { if (configuration != null) { if (configuration instanceof RedissonConfiguration) { configuration = ((RedissonConfiguration<K, V>)configuration).getJcacheConfig(); } if (configuration instanceof CompleteConfiguration) { delegate = new MutableConfiguration<K, V>((CompleteConfiguration<K, V>) configuration); } else { delegate = new MutableConfiguration<K, V>(); delegate.setStoreByValue(configuration.isStoreByValue()); delegate.setTypes(configuration.getKeyType(), configuration.getValueType()); } } else { delegate = new MutableConfiguration<K, V>(); } this.expiryPolicy = delegate.getExpiryPolicyFactory().create(); }
public JCacheConfiguration(Configuration<K, V> configuration) { if (configuration != null) { if (configuration instanceof RedissonConfiguration) { configuration = ((RedissonConfiguration<K, V>)configuration).getJcacheConfig(); } if (configuration instanceof CompleteConfiguration) { delegate = new MutableConfiguration<K, V>((CompleteConfiguration<K, V>) configuration); } else { delegate = new MutableConfiguration<K, V>(); delegate.setStoreByValue(configuration.isStoreByValue()); delegate.setTypes(configuration.getKeyType(), configuration.getValueType()); } } else { delegate = new MutableConfiguration<K, V>(); } this.expiryPolicy = delegate.getExpiryPolicyFactory().create(); }
protected <K, T> Cache<K, SerializedEntity<T>> createCache(String cacheName, Type<T> type) { Class keyClass = getKeyClass(type); if (keyClass == null) { throw new IllegalStateException(); } MutableConfiguration<K, SerializedEntity<T>> configuration = new MutableConfiguration<>(); configuration.setTypes(keyClass, (Class) SerializedEntity.class); configure(configuration); return cacheManager.createCache(cacheName, configuration); }
<K, V> void createCache(final CacheManager cacheManager, final String cacheName, final Class<K> keyType, final Class<V> valueType) { final Configuration jcacheConfig = new MutableConfiguration().setTypes(keyType, valueType); final Configuration redissonConfiguration = RedissonConfiguration.fromInstance(redissonClient, jcacheConfig); createCache(cacheManager, cacheName, redissonConfiguration); } }
<K, V> void createCache(final CacheManager cacheManager, final String cacheName, final Class<K> keyType, final Class<V> valueType) { // All other configuration options come from the ehcache.xml final Configuration configuration = new MutableConfiguration<K, V>().setTypes(keyType, valueType) .setStoreByValue(false); // Store by reference to avoid copying large objects (e.g. catalog) super.createCache(cacheManager, cacheName, configuration); } }
@Bean public CacheManager jCacheManager() { CacheManager cacheManager = this.cachingProvider.getCacheManager(); MutableConfiguration<Object, Object> mutableConfiguration = new MutableConfiguration<>(); mutableConfiguration.setStoreByValue(false); // otherwise value has to be Serializable cacheManager.createCache("testCache", mutableConfiguration); cacheManager.createCache("primary", mutableConfiguration); cacheManager.createCache("secondary", mutableConfiguration); return cacheManager; }
JCacheProfiler() { random = new Random(); count = new LongAdder(); CachingProvider provider = Caching.getCachingProvider(CaffeineCachingProvider.class.getName()); CacheManager cacheManager = provider.getCacheManager( provider.getDefaultURI(), provider.getDefaultClassLoader()); cache = cacheManager.createCache("profiler", new MutableConfiguration<>()); executor = Executors.newCachedThreadPool(new ThreadFactoryBuilder() .setPriority(Thread.MIN_PRIORITY).setDaemon(true).build()); }
@Override public void buildEntityManagerFactory() { JCacheHelper.locateStandardCacheManager().createCache( "default-update-timestamps-region", new MutableConfiguration<>() ); JCacheHelper.locateStandardCacheManager().createCache( "default-query-results-region", new MutableConfiguration<>() ); JCacheHelper.locateStandardCacheManager().createCache( "org.hibernate.userguide.mapping.identifier.CacheableNaturalIdTest$Book##NaturalId", new MutableConfiguration<>() ); // JCacheHelper.locateStandardCacheManager().createCache( "", new MutableConfiguration<>() ); super.buildEntityManagerFactory(); }
@Before public void setup() { this.cacheManager = getCachingProvider().getCacheManager(); this.cacheManager.createCache(CACHE_NAME, new MutableConfiguration<>()); this.cacheManager.createCache(CACHE_NAME_NO_NULL, new MutableConfiguration<>()); this.nativeCache = this.cacheManager.getCache(CACHE_NAME); this.cache = new JCacheCache(this.nativeCache); Cache<Object, Object> nativeCacheNoNull = this.cacheManager.getCache(CACHE_NAME_NO_NULL); this.cacheNoNull = new JCacheCache(nativeCacheNoNull, false); }
@BeforeClass public void beforeClass() { final CachingProvider provider = Caching.getCachingProvider(PROVIDER_NAME); cacheManager = provider.getCacheManager(); cacheManager.destroyCache("cache-not-in-config-file"); cacheConfig = new MutableConfiguration<>(); cacheConfig.setTypes(String.class, String.class); cacheConfig.setStatisticsEnabled(true); }
@Test public void jsr107LoaderInitAlways() { CacheLoader<Object, Object> loader = mock(CacheLoader.class); MutableConfiguration<Object, Object> configuration = new MutableConfiguration<>(); RecordingFactory<CacheLoader<Object, Object>> factory = factoryOf(loader); configuration.setCacheLoaderFactory(factory); ConfigurationMerger.ConfigHolder<Object, Object> configHolder = merger.mergeConfigurations("cache", configuration); assertThat(factory.called, is(true)); assertThat(configHolder.cacheResources.getCacheLoaderWriter(), notNullValue()); assertThat(configHolder.useEhcacheLoaderWriter, is(false)); }
public static void createCache(CacheManager cacheManager, String name, boolean usePrefix) { if ( usePrefix ) { name = prefix( name ); } if ( cacheManager.getCache( name ) != null ) { cacheManager.destroyCache( name ); } cacheManager.createCache( name, new MutableConfiguration<>() ); }
public JCache(URL url) { String method = url.getParameter(Constants.METHOD_KEY, ""); String key = url.getAddress() + "." + url.getServiceKey() + "." + method; // jcache parameter is the full-qualified class name of SPI implementation String type = url.getParameter("jcache"); CachingProvider provider = StringUtils.isEmpty(type) ? Caching.getCachingProvider() : Caching.getCachingProvider(type); CacheManager cacheManager = provider.getCacheManager(); Cache<Object, Object> cache = cacheManager.getCache(key); if (cache == null) { try { //configure the cache MutableConfiguration config = new MutableConfiguration<Object, Object>() .setTypes(Object.class, Object.class) .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, url.getMethodParameter(method, "cache.write.expire", 60 * 1000)))) .setStoreByValue(false) .setManagementEnabled(true) .setStatisticsEnabled(true); cache = cacheManager.createCache(key, config); } catch (CacheException e) { // concurrent cache initialization cache = cacheManager.getCache(key); } } this.store = cache; }
public JCache(URL url) { String method = url.getParameter(Constants.METHOD_KEY, ""); String key = url.getAddress() + "." + url.getServiceKey() + "." + method; // jcache parameter is the full-qualified class name of SPI implementation String type = url.getParameter("jcache"); CachingProvider provider = StringUtils.isEmpty(type) ? Caching.getCachingProvider() : Caching.getCachingProvider(type); CacheManager cacheManager = provider.getCacheManager(); Cache<Object, Object> cache = cacheManager.getCache(key); if (cache == null) { try { //configure the cache MutableConfiguration config = new MutableConfiguration<Object, Object>() .setTypes(Object.class, Object.class) .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MILLISECONDS, url.getMethodParameter(method, "cache.write.expire", 60 * 1000)))) .setStoreByValue(false) .setManagementEnabled(true) .setStatisticsEnabled(true); cache = cacheManager.createCache(key, config); } catch (CacheException e) { // concurrent cache initialization cache = cacheManager.getCache(key); } } this.store = cache; }