new SingleFileStoreConfigurationBuilder(persistConfig).location(location); fileStore.invocationBatching().enable(); fileStore.eviction().maxEntries(15); fileStore.eviction().strategy(EvictionStrategy.LRU); fileStore.jmxStatistics().disable();
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() {
/** * Overrides the default embedded cache manager. */ @Produces @ApplicationScoped @SuppressWarnings("unused") public EmbeddedCacheManager defaultCacheManager() { ConfigurationBuilder builder = new ConfigurationBuilder(); builder.eviction().maxEntries(7); return TestCacheManagerFactory.createCacheManager(builder); }
@Produces public Configuration customDefaultConfiguration() { return new ConfigurationBuilder() .eviction().maxEntries(16) .build(); } }
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); }
/** * <p>Defines the "large" cache configuration.</p> * * <p>This cache will be registered with the produced configuration in the default cache manager.</p> */ @Large @ConfigureCache("large") @Produces @SuppressWarnings("unused") public Configuration largeConfiguration() { return new ConfigurationBuilder() .eviction().maxEntries(1024) .build(); }
/** * <p>Configures a "tiny" cache (with a very low number of entries), and associates it with the qualifier {@link * Tiny}.</p> * * <p>This will use the default cache container.</p> */ @Tiny @ConfigureCache("tiny") @Produces public Configuration tinyConfiguration() { return new ConfigurationBuilder() .eviction().maxEntries(1) .build(); }
/** * <p>Defines the "very-large" cache configuration.</p> * * <p>This cache will be registered with the produced configuration in the specific cache manager.</p> */ @VeryLarge @ConfigureCache("very-large") @Produces @SuppressWarnings("unused") public Configuration veryLargeConfiguration() { return new ConfigurationBuilder() .eviction().maxEntries(4096) .build(); }
/** * <p>Configures a "small" cache (with a pretty low number of entries), and associates it with the qualifier {@link * Small}.</p> * * <p>This will use the default cache container.</p> */ @Small @ConfigureCache("small") @Produces public Configuration smallConfiguration() { return new ConfigurationBuilder() .eviction().maxEntries(10) .build(); } }
/** * Return the uri -> KiWiUriResource cache from the cache manager. This cache is used when constructing new * KiWiUriResources to avoid a database lookup. * * @return */ public Map getUriCache() { if(uriCache == null) { Configuration uriConfiguration = new ConfigurationBuilder().read(defaultConfiguration) .eviction() .maxEntries(config.getUriCacheSize()) .build(); cacheManager.defineConfiguration(URI_CACHE, uriConfiguration); uriCache = new AsyncMap(cacheManager.getCache(URI_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP)); } return uriCache; }
/** * Return the anonId -> KiWiAnonResource cache from the cache manager. This cache is used when constructing new * KiWiAnonResources to avoid a database lookup. * * @return */ public Map getBNodeCache() { if(bnodeCache == null) { Configuration bnodeConfiguration = new ConfigurationBuilder().read(defaultConfiguration) .eviction() .maxEntries(config.getBNodeCacheSize()) .build(); cacheManager.defineConfiguration(BNODE_CACHE, bnodeConfiguration); bnodeCache = new AsyncMap(cacheManager.getCache(BNODE_CACHE).getAdvancedCache().withFlags(Flag.SKIP_LOCKING, Flag.SKIP_CACHE_LOAD, Flag.SKIP_REMOTE_LOOKUP)); } return bnodeCache; }
/** * Overrides the default embedded cache manager to define the quick and large cache configurations externally. */ @Produces @ApplicationScoped @SuppressWarnings("unused") public EmbeddedCacheManager defaultCacheManager() { EmbeddedCacheManager externalCacheContainerManager = TestCacheManagerFactory.createCacheManager(false); // define large configuration externalCacheContainerManager.defineConfiguration("large", new ConfigurationBuilder() .eviction().maxEntries(100) .build()); // define quick configuration externalCacheContainerManager.defineConfiguration("quick", new ConfigurationBuilder() .expiration().wakeUpInterval(1l) .build()); return externalCacheContainerManager; }
/** * Associates the "small" cache with the qualifier {@link Small}. * * @param cacheManager the specific cache manager associated to this cache. This cache manager is used to get the * default cache configuration. */ @Small @ConfigureCache("small") @Produces @SuppressWarnings("unused") public Configuration smallConfiguration(@Small EmbeddedCacheManager cacheManager) { return new ConfigurationBuilder() .read(cacheManager.getDefaultCacheConfiguration()) .eviction().maxEntries(20) .build(); }
/** * Associates the "large" cache with the qualifier {@link Large}. * * @param cacheManager the specific cache manager associated to this cache. This cache manager is used to get the * default cache configuration. */ @Large @ConfigureCache("large") @Produces @SuppressWarnings("unused") public Configuration largeConfiguration(@Large EmbeddedCacheManager cacheManager) { return new ConfigurationBuilder() .read(cacheManager.getDefaultCacheConfiguration()) .eviction().maxEntries(2000) .build(); }
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); }