fileStore.invocationBatching().enable(); fileStore.eviction().maxEntries(15); fileStore.eviction().strategy(EvictionStrategy.LRU); fileStore.jmxStatistics().disable(); final Configuration config = persistConfig.addStore(fileStore).build();
protected ServerCache getDefaultCache() { GlobalConfiguration gconfig = new GlobalConfigurationBuilder() .globalJmxStatistics() .allowDuplicateDomains(true) .enable() .jmxDomain("custom-cache") .build(); Configuration configuration = new ConfigurationBuilder() .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100) .jmxStatistics().enable() .build(); EmbeddedCacheManager manager = new DefaultCacheManager(gconfig, configuration); Cache<Object, Object> c = manager.getCache("custom-cache"); return new InfinispanCache(c); }
void evict() { builder.eviction() .strategy(EvictionStrategy.valueOf(options.getString(Caching.CreateOption.EVICTION).toUpperCase())) .maxEntries(options.getInt(Caching.CreateOption.MAX_ENTRIES)); } void expire() {
/** * Creates a new ExoCache instance with the relevant parameters * @throws ExoCacheInitException If any exception occurs while creating the cache */ private ExoCache<Serializable, Object> create(ExoCacheConfig config, ConfigurationBuilder confBuilder, Callable<Cache<Serializable, Object>> cacheGetter, String strategy, int maxEntries, long lifespan, long maxIdle, long wakeUpInterval) throws ExoCacheInitException { EvictionStrategy es = strategy == null || strategy.length() == 0 ? null : EvictionStrategy.valueOf(strategy .toUpperCase(Locale.ENGLISH)); if (es == null) { es = EvictionStrategy.LRU; } confBuilder.eviction().strategy(EvictionStrategy.valueOf(strategy)).maxEntries(maxEntries).expiration() .lifespan(lifespan).maxIdle(maxIdle).wakeUpInterval(wakeUpInterval); try { return new GenericExoCache(config, cacheGetter.call()); } catch (Exception e)//NOSONAR { throw new ExoCacheInitException("Cannot create the cache '" + config.getName() + "'", e); } }
protected Cache getDefaultCache() { EmbeddedCacheManager manager = new DefaultCacheManager(); manager.defineConfiguration("custom-cache", new ConfigurationBuilder() .eviction().strategy(EvictionStrategy.NONE).maxEntries(1000) .build()); return manager.getCache("custom-cache"); }
public static void main(String args[]) throws Exception { EmbeddedCacheManager manager = new DefaultCacheManager(); manager.defineConfiguration("custom-cache", new ConfigurationBuilder() .eviction().strategy(LIRS).maxEntries(10) .build()); Cache<Object, Object> c = manager.getCache("custom-cache"); }
/** * Clean the configuration template to prevent conflicts */ protected void resetConfiguration(ConfigurationBuilder confBuilder) { confBuilder.invocationBatching().enable().eviction().strategy(EvictionStrategy.NONE).maxEntries(-1).expiration() .lifespan(-1L).maxIdle(-1L).wakeUpInterval(60000L); } }
/** * Associates the "small" and "large" caches with this specific cache manager. */ @Large @Small @Produces @ApplicationScoped @SuppressWarnings("unused") public EmbeddedCacheManager specificCacheManager() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.eviction().maxEntries(4000).strategy(EvictionStrategy.LIRS); return TestCacheManagerFactory.createCacheManager(builder); }
/** * Build a local cache configuration. * <p/> * In local cache mode, the cache is not shared among the servers in a cluster. Each machine keeps a local cache. * This allows quick startups and eliminates network traffic in the cluster, but subsequent requests to different * cluster members cannot benefit from the cached data. */ protected void buildLocalConfiguration() { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder() .classLoader(InfinispanEmbeddedCacheManager.class.getClassLoader()) .globalJmxStatistics() .jmxDomain("org.apache.marmotta.kiwi") .allowDuplicateDomains(true) .build(); defaultConfiguration = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.LOCAL) .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100000) .expiration() .lifespan(5, TimeUnit.MINUTES) .maxIdle(1, TimeUnit.MINUTES) .build(); cacheManager = new DefaultCacheManager(globalConfiguration, defaultConfiguration, true); log.info("initialised Infinispan local cache manager"); }
.timeout(config.getClusterTimeout()) .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100000) .expiration()
/** * Create and return the cache used by the CacheTripleRegistry. This is an unlimited synchronous replicated * cache and should be used with care. * @return */ public Map getRegistryCache() { if(registryCache == null) { if(isClustered()) { Configuration registryConfiguration = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.REPL_SYNC) .sync() .replTimeout(15, TimeUnit.SECONDS) .eviction() .strategy(EvictionStrategy.NONE) .build(); cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration); } else { Configuration registryConfiguration = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.LOCAL) .eviction() .strategy(EvictionStrategy.NONE) .build(); cacheManager.defineConfiguration(REGISTRY_CACHE, registryConfiguration); } registryCache = cacheManager.getCache(REGISTRY_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP); } return registryCache; }
/** * Create a non-clustered instance of the infinispan cache. */ public LDCachingInfinispanBackend() { globalConfiguration = new GlobalConfigurationBuilder() .classLoader(LDCachingInfinispanBackend.class.getClassLoader()) .globalJmxStatistics() .jmxDomain("org.apache.marmotta.ldcache") .allowDuplicateDomains(true) .build(); defaultConfiguration = new ConfigurationBuilder() .clustering() .cacheMode(CacheMode.LOCAL) .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100000) .expiration() .lifespan(7, TimeUnit.DAYS) .maxIdle(1, TimeUnit.DAYS) .build(); clustered = false; }
.timeout(config.getClusterTimeout()) .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100000) .expiration()
private org.infinispan.Cache<NotificationId, SubscriptionId> createCache() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.loaders() .passivation(true) .addFileCacheStore() .location(super.diskStorePath) .purgeOnStartup(true) .async() .eviction() .maxEntries( EventCloudProperties.SUBSCRIBER_CACHE_MAX_ENTRIES.getValue()) .strategy(EvictionStrategy.LRU) .locking() .isolationLevel(IsolationLevel.NONE); this.cacheManager.defineConfiguration("default", builder.build()); return this.cacheManager.<NotificationId, SubscriptionId> getCache("default"); }
protected ServerCache getDefaultCache() { GlobalConfiguration gconfig = new GlobalConfigurationBuilder() .globalJmxStatistics() .allowDuplicateDomains(true) .enable() .jmxDomain("custom-cache") .build(); Configuration configuration = new ConfigurationBuilder() .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100) .jmxStatistics().enable() .build(); EmbeddedCacheManager manager = new DefaultCacheManager(gconfig, configuration); Cache<Object, Object> c = manager.getCache("custom-cache"); return new InfinispanCache(c); }
.fetchInMemoryState(false) .eviction() .strategy(EvictionStrategy.LIRS) .maxEntries(100000) .expiration()
builder = builder.eviction().strategy(evictionStrategy);
confBuilder.eviction().strategy(EvictionStrategy.NONE); confBuilder.eviction().maxEntries(-1);
confBuilder.eviction().strategy(EvictionStrategy.NONE); confBuilder.eviction().maxEntries(-1);