org.infinispan.eviction.EvictionStrategy Java Examples
The following examples show how to use
org.infinispan.eviction.EvictionStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InfinispanCacheTestConfiguration.java From infinispan-spring-boot with Apache License 2.0 | 6 votes |
@Bean public InfinispanCacheConfigurer cacheConfigurer() { return cacheManager -> { final org.infinispan.configuration.cache.ConfigurationBuilder testCacheBuilder = new ConfigurationBuilder(); testCacheBuilder.simpleCache(true) .memory() .storageType(StorageType.OBJECT) .evictionType(EvictionType.COUNT) .evictionStrategy(EvictionStrategy.MANUAL); testCacheBuilder.statistics().enable(); cacheManager.defineConfiguration(TEST_CACHE_NAME, testCacheBuilder.build()); }; }
Example #2
Source File: ClusterManager.java From glowroot with Apache License 2.0 | 6 votes |
private static Configuration createCacheConfiguration(int size) { ConfigurationBuilder configurationBuilder = new ConfigurationBuilder(); // "max idle" is to keep memory down for deployments with few agents // "size" is to keep memory bounded for deployments with lots of agents configurationBuilder.clustering() .cacheMode(CacheMode.INVALIDATION_ASYNC) .expiration() .maxIdle(30, MINUTES) .memory() .size(size) .evictionType(EvictionType.COUNT) .evictionStrategy(EvictionStrategy.REMOVE) .jmxStatistics() .enable(); return configurationBuilder.build(); }
Example #3
Source File: InfinispanCacheFactory.java From cache2k-benchmark with Apache License 2.0 | 6 votes |
@Override protected <K, V> BenchmarkCache<K, V> createSpecialized(final Class<K> _keyType, final Class<V> _valueType, final int _maxElements) { EmbeddedCacheManager m = getCacheMangaer(); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.eviction().maxEntries(_maxElements); cb.storeAsBinary().disable(); if (!withExpiry) { cb.expiration().disableReaper().lifespan(-1); } else { cb.expiration().lifespan(5 * 60, TimeUnit.SECONDS); } switch (algorithm) { case LRU: cb.eviction().strategy(EvictionStrategy.LRU); break; case LIRS: cb.eviction().strategy(EvictionStrategy.LIRS); break; case UNORDERED: cb.eviction().strategy(EvictionStrategy.UNORDERED); break; } m.defineConfiguration(CACHE_NAME, cb.build()); Cache<Integer, Integer> _cache = m.getCache(CACHE_NAME); return new MyBenchmarkCache(_cache); }
Example #4
Source File: InfinispanEmbeddedCacheConfig.java From spring4-sandbox with Apache License 2.0 | 6 votes |
@Override @Bean public CacheManager cacheManager() { return new SpringEmbeddedCacheManager( new DefaultCacheManager( new ConfigurationBuilder() .eviction() .maxEntries(20000) .strategy(EvictionStrategy.LIRS) .expiration() .wakeUpInterval(5000L) .maxIdle(120000L) .build() ) ); }
Example #5
Source File: DefaultInfinispanConnectionProviderFactory.java From keycloak with Apache License 2.0 | 6 votes |
private Configuration getRevisionCacheConfig(long maxEntries) { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.invocationBatching().enable().transaction().transactionMode(TransactionMode.TRANSACTIONAL); // Use Embedded manager even in managed ( wildfly/eap ) environment. We don't want infinispan to participate in global transaction cb.transaction().transactionManagerLookup(new EmbeddedTransactionManagerLookup()); cb.transaction().lockingMode(LockingMode.PESSIMISTIC); cb.memory() .evictionStrategy(EvictionStrategy.REMOVE) .evictionType(EvictionType.COUNT) .size(maxEntries); return cb.build(); }
Example #6
Source File: InfinispanKeyStorageProviderTest.java From keycloak with Apache License 2.0 | 6 votes |
protected Cache<String, PublicKeysEntry> getKeysCache() { GlobalConfigurationBuilder gcb = new GlobalConfigurationBuilder(); gcb.globalJmxStatistics().allowDuplicateDomains(true).enabled(true); final DefaultCacheManager cacheManager = new DefaultCacheManager(gcb.build()); ConfigurationBuilder cb = new ConfigurationBuilder(); cb.memory() .evictionStrategy(EvictionStrategy.REMOVE) .evictionType(EvictionType.COUNT) .size(InfinispanConnectionProvider.KEYS_CACHE_DEFAULT_MAX); cb.jmxStatistics().enabled(true); Configuration cfg = cb.build(); cacheManager.defineConfiguration(InfinispanConnectionProvider.KEYS_CACHE_NAME, cfg); return cacheManager.getCache(InfinispanConnectionProvider.KEYS_CACHE_NAME); }
Example #7
Source File: TestPersistence.java From hacep with Apache License 2.0 | 5 votes |
@Override public ConfigurationBuilder extendDefaultConfiguration(ConfigurationBuilder builder) { SingleFileStoreConfigurationBuilder sfcb = builder .persistence() .passivation(false) .addSingleFileStore() .shared(false) .preload(true) .fetchPersistentState(true) .purgeOnStartup(false); if( nodeSelector == 1 ){ sfcb.location(persistenceLocation); } else if( nodeSelector == 2) { sfcb.location(persistenceLocation2); } else if( nodeSelector == 3) { sfcb.location(persistenceLocation3); } else { throw new UnsupportedOperationException("Node id unknown"); } sfcb.singleton().enabled(false) .eviction() .strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(1024); return builder; }
Example #8
Source File: InfinispanEmbeddedAutoConfigurationIntegrationConfigurerTest.java From infinispan-spring-boot with Apache License 2.0 | 5 votes |
@Test public void testWithCacheConfigurer() { assertThat(defaultCacheManager.getCacheNames()).containsExactlyInAnyOrder(InfinispanCacheTestConfiguration.TEST_CACHE_NAME, "default"); final Configuration testCacheConfiguration = defaultCacheManager.getCacheConfiguration(InfinispanCacheTestConfiguration.TEST_CACHE_NAME); assertThat(testCacheConfiguration.statistics().enabled()).isTrue(); assertThat(testCacheConfiguration.memory().storageType()).isEqualTo(StorageType.OBJECT); assertThat(testCacheConfiguration.memory().evictionType()).isEqualTo(EvictionType.COUNT); assertThat(testCacheConfiguration.memory().evictionStrategy()).isEqualTo(EvictionStrategy.MANUAL); }
Example #9
Source File: DefaultInfinispanConnectionProviderFactory.java From keycloak with Apache License 2.0 | 5 votes |
protected Configuration getKeysCacheConfig() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.memory() .evictionStrategy(EvictionStrategy.REMOVE) .evictionType(EvictionType.COUNT) .size(InfinispanConnectionProvider.KEYS_CACHE_DEFAULT_MAX); cb.expiration().maxIdle(InfinispanConnectionProvider.KEYS_CACHE_MAX_IDLE_SECONDS, TimeUnit.SECONDS); return cb.build(); }
Example #10
Source File: DefaultInfinispanConnectionProviderFactory.java From keycloak with Apache License 2.0 | 5 votes |
private ConfigurationBuilder getActionTokenCacheConfig() { ConfigurationBuilder cb = new ConfigurationBuilder(); cb.memory() .evictionStrategy(EvictionStrategy.NONE) .evictionType(EvictionType.COUNT) .size(InfinispanConnectionProvider.ACTION_TOKEN_CACHE_DEFAULT_MAX); cb.expiration() .maxIdle(InfinispanConnectionProvider.ACTION_TOKEN_MAX_IDLE_SECONDS, TimeUnit.SECONDS) .wakeUpInterval(InfinispanConnectionProvider.ACTION_TOKEN_WAKE_UP_INTERVAL_SECONDS, TimeUnit.SECONDS); return cb; }
Example #11
Source File: DataGridManager.java From hacep with Apache License 2.0 | 4 votes |
public void start(HAKieSessionBuilder builder, String nodeName) { if (started.compareAndSet(false, true)) { GlobalConfiguration globalConfiguration = new GlobalConfigurationBuilder().clusteredDefault() .transport().addProperty("configurationFile", System.getProperty("jgroups.configuration", "jgroups-tcp.xml")) .clusterName("HACEP").nodeName(nodeName) .globalJmxStatistics().allowDuplicateDomains(true).enable() .serialization() .addAdvancedExternalizer(new HAKieSession.HASessionExternalizer(builder)) .addAdvancedExternalizer(new HAKieSerializedSession.HASerializedSessionExternalizer(builder)) .addAdvancedExternalizer(new HAKieSessionDeltaEmpty.HASessionDeltaEmptyExternalizer(builder)) .addAdvancedExternalizer(new HAKieSessionDeltaFact.HASessionDeltaFactExternalizer(builder)) .build(); ConfigurationBuilder commonConfigurationBuilder = new ConfigurationBuilder(); CacheMode cacheMode = getCacheMode(); if (cacheMode.isDistributed()) { commonConfigurationBuilder .clustering().cacheMode(cacheMode) .hash().numOwners(getNumOwners()) .groups().enabled(); } else { commonConfigurationBuilder.clustering().cacheMode(cacheMode); } Configuration commonConfiguration = commonConfigurationBuilder.build(); this.manager = new DefaultCacheManager(globalConfiguration, commonConfiguration, false); ConfigurationBuilder factCacheConfigurationBuilder = new ConfigurationBuilder().read(commonConfiguration); factCacheConfigurationBuilder .expiration() .maxIdle(factsExpiration(), TimeUnit.MILLISECONDS); ConfigurationBuilder sessionCacheConfigurationBuilder = new ConfigurationBuilder().read(commonConfiguration); if (persistence()) { sessionCacheConfigurationBuilder .persistence() .passivation(isPassivated()) .addSingleFileStore() .shared(shared()) .preload(preload()) .fetchPersistentState(fetchPersistentState()) .purgeOnStartup(purgeOnStartup()) .location(location()) .async().threadPoolSize(threadPoolSize()).enabled(false) .singleton().enabled(false) .eviction() .strategy(EvictionStrategy.LRU).type(EvictionType.COUNT).size(evictionSize()); } this.manager.defineConfiguration(FACT_CACHE_NAME, factCacheConfigurationBuilder.build()); this.manager.defineConfiguration(SESSION_CACHE_NAME, sessionCacheConfigurationBuilder.build()); this.manager.start(); } }
Example #12
Source File: SimpleInfinispanCacheInfo.java From geomajas-project-server with GNU Affero General Public License v3.0 | 2 votes |
/** * Set the eviction strategy to use. Can be UNORDERED, FIFO, LRU and NONE. * <p/> * This indicates the which items need to be removed from cache to make space for more new entries. The cached item * may still be available after eviction if there is a secondary cache (disk). * * @param evictionStrategy eviction strategy */ public void setEvictionStrategy(EvictionStrategy evictionStrategy) { this.evictionStrategy = evictionStrategy; }