@ManagedName("Lifespan") @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide." + " -1 means the entries never expire.") public long getLiveTime() { return cache.getCacheConfiguration().expiration().lifespan(); }
@ManagedName("Lifespan") @ManagedDescription("Maximum lifespan of a cache entry, after which the entry is expired cluster-wide." + " -1 means the entries never expire.") public long getLiveTime() { return cache.getCacheConfiguration().expiration().lifespan(); }
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
@Managed @ManagedName("MaxIdle") @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. " + "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.") public long getMaxIdle() { return cache.getCacheConfiguration().expiration().maxIdle(); }
@Managed @ManagedName("WakeUpInterval") @ManagedDescription("Interval between subsequent eviction runs. If you wish to disable the periodic eviction " + "process altogether, set wakeupInterval to -1.") public long getWakeUpInterval() { return cache.getCacheConfiguration().expiration().wakeUpInterval(); }
@Managed @ManagedName("MaxIdle") @ManagedDescription("Maximum idle time a cache entry will be maintained in the cache. " + "If the idle time is exceeded, the entry will be expired cluster-wide. -1 means the entries never expire.") public long getMaxIdle() { return cache.getCacheConfiguration().expiration().maxIdle(); }
@Managed @ManagedName("WakeUpInterval") @ManagedDescription("Interval between subsequent eviction runs. If you wish to disable the periodic eviction " + "process altogether, set wakeupInterval to -1.") public long getWakeUpInterval() { return cache.getCacheConfiguration().expiration().wakeUpInterval(); } }
@Override public void call() { Configuration wildcache1 = cm.getCacheConfiguration("wildcache1"); assertNotNull(wildcache1); assertEquals(10500, wildcache1.expiration().wakeUpInterval()); assertEquals(11, wildcache1.expiration().lifespan()); assertEquals(11, wildcache1.expiration().maxIdle()); }
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().eviction().maxEntries(), 1000); assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
public void testJCacheManagerWithWildcardCacheConfigurations() throws Exception { URI uri = JCacheConfigurationTest.class.getClassLoader().getResource("infinispan_uri.xml").toURI(); withCachingProvider(provider -> { JCacheManager jCacheManager = new JCacheManager( uri, provider.getClass().getClassLoader(), provider, null); Cache<Object, Object> wildcache1 = jCacheManager.createCache("wildcache1", new MutableConfiguration<>()); org.infinispan.Cache unwrap = wildcache1.unwrap(org.infinispan.Cache.class); Configuration configuration = unwrap.getCacheConfiguration(); assertEquals(10500, configuration.expiration().wakeUpInterval()); assertEquals(11, configuration.expiration().lifespan()); assertEquals(11, configuration.expiration().maxIdle()); }); }
private static Cache<?, ?> checkValidConfiguration(final Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.expiration().maxIdle() != -1) { throw log.luceneStorageHavingIdleTimeSet(indexName, cache.getName()); } if (configuration.expiration().lifespan() != -1) { throw log.luceneStorageHavingLifespanSet(indexName, cache.getName()); } if (configuration.memory().storageType() == StorageType.BINARY) { throw log.luceneStorageAsBinaryEnabled(indexName, cache.getName()); } if (!Configurations.noDataLossOnJoiner(configuration)) { throw log.luceneStorageNoStateTransferEnabled(indexName, cache.getName()); } return cache; }
private static Cache<?, ?> checkValidConfiguration(final Cache<?, ?> cache, String indexName) { Configuration configuration = cache.getCacheConfiguration(); if (configuration.expiration().maxIdle() != -1) { throw log.luceneStorageHavingIdleTimeSet(indexName, cache.getName()); } if (configuration.expiration().lifespan() != -1) { throw log.luceneStorageHavingLifespanSet(indexName, cache.getName()); } if (configuration.memory().storageType() == StorageType.BINARY) { throw log.luceneStorageAsBinaryEnabled(indexName, cache.getName()); } if (!Configurations.noDataLossOnJoiner(configuration)) { throw log.luceneStorageNoStateTransferEnabled(indexName, cache.getName()); } return cache; }
@Test public void testCustomPendingPutsCache() { Properties p = createProperties(); p.setProperty(INFINISPAN_CONFIG_RESOURCE_PROP, "alternative-infinispan-configs.xml"); TestRegionFactory factory = createRegionFactory(p); try { Configuration ppConfig = factory.getCacheManager().getCacheConfiguration(DEF_PENDING_PUTS_RESOURCE); assertEquals(120000, ppConfig.expiration().maxIdle()); } finally { factory.stop(); } }
@Test public void testBuildTimestampsRegionWithNoneEvictionOverride() { final String timestamps = "org.hibernate.cache.spi.UpdateTimestampsCache"; final String timestampsNoEviction = "timestamps-no-eviction"; Properties p = createProperties(); p.setProperty("hibernate.cache.infinispan.timestamps.cfg", timestampsNoEviction); p.setProperty("hibernate.cache.infinispan.timestamps.memory.size", "0"); p.setProperty("hibernate.cache.infinispan.timestamps.expiration.wake_up_interval", "3000"); TestRegionFactory factory = createRegionFactory(p); try { InfinispanBaseRegion region = factory.buildTimestampsRegion(timestamps); assertTrue( isDefinedCache(factory, timestamps) ); assertEquals(3000, region.getCache().getCacheConfiguration().expiration().wakeUpInterval()); } finally { factory.stop(); } }
public void testQuickCache() { assertEquals(quickCache.getCacheConfiguration().memory().size(), 1000); assertEquals(quickCache.getCacheConfiguration().expiration().wakeUpInterval(), 1); } }
@Override protected void startUp() { super.startUp(); TestRegionFactory regionFactory = TestRegionFactoryProvider.load().wrap(sessionFactory().getSettings().getRegionFactory()); TIMEOUT = regionFactory.getPendingPutsCacheConfiguration().expiration().maxIdle(); region = TEST_SESSION_ACCESS.getRegion(sessionFactory(), Item.class.getName()); entityCache = region.getCache(); }
@Override protected void startInternal(MemcachedServerConfiguration configuration, EmbeddedCacheManager cacheManager) { if (cacheManager.getCacheConfiguration(configuration.defaultCacheName()) == null) { // Define the Memcached cache as clone of the default one cacheManager.defineConfiguration(configuration.defaultCacheName(), new ConfigurationBuilder().read(cacheManager.getDefaultCacheConfiguration()).build()); } ExpirationConfiguration expConfig = cacheManager.getCacheConfiguration(configuration.defaultCacheName()).expiration(); if (expConfig.lifespan() >= 0 || expConfig.maxIdle() >= 0) throw log.invalidExpiration(configuration.defaultCacheName()); Cache<byte[], byte[]> cache = cacheManager.getCache(configuration.defaultCacheName()); memcachedCache = cache.getAdvancedCache(); super.startInternal(configuration, cacheManager); }
@Before public void insertAndClearCache() throws Exception { region = TEST_SESSION_ACCESS.getRegion(sessionFactory(), Item.class.getName()); entityCache = region.getCache(); timeout = TestRegionFactoryProvider.load().findRegionFactory(sessionFactory().getCache()) .getPendingPutsCacheConfiguration().expiration().maxIdle(); Item item = new Item("my item", "Original item"); withTxSession(s -> s.persist(item)); entityCache.clear(); assertEquals("Cache is not empty", Collections.EMPTY_SET, entityCache.keySet()); itemId = item.getId(); log.info("Insert and clear finished"); }
@Test public void testDefaultPendingPutsCache() { Properties p = createProperties(); TestRegionFactory factory = createRegionFactory(p); try { Configuration ppConfig = factory.getCacheManager().getCacheConfiguration(DEF_PENDING_PUTS_RESOURCE); assertTrue(ppConfig.isTemplate()); assertFalse(ppConfig.clustering().cacheMode().isClustered()); assertTrue(ppConfig.simpleCache()); assertEquals(TransactionMode.NON_TRANSACTIONAL, ppConfig.transaction().transactionMode()); assertEquals(60000, ppConfig.expiration().maxIdle()); assertFalse(ppConfig.jmxStatistics().enabled()); assertFalse(ppConfig.jmxStatistics().available()); } finally { factory.stop(); } }