javax.cache.expiry.CreatedExpiryPolicy Java Examples
The following examples show how to use
javax.cache.expiry.CreatedExpiryPolicy.
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: IgnitePdsContinuousRestartTestWithExpiryPolicy.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = new CacheConfiguration(); ccfg.setName(CACHE_NAME); ccfg.setGroupName("Group1"); ccfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL); ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC); ccfg.setAffinity(new RendezvousAffinityFunction(false, 128)); ccfg.setBackups(2); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1))); cfg.setCacheConfiguration(ccfg); return cfg; }
Example #2
Source File: GridCacheAbstractLocalStoreSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception If failed. */ @Test public void testEvict() throws Exception { Ignite ignite1 = startGrid(1); IgniteCache<Object, Object> cache = ignite1.cache(DEFAULT_CACHE_NAME).withExpiryPolicy(new CreatedExpiryPolicy( new Duration(TimeUnit.MILLISECONDS, 100L))); // Putting entry. for (int i = 0; i < KEYS; i++) cache.put(i, i); // Wait when entry U.sleep(200); // Check that entry is evicted from cache, but local store does contain it. for (int i = 0; i < KEYS; i++) { cache.localEvict(Arrays.asList(i)); assertNull(cache.localPeek(i)); assertEquals(i, (int)LOCAL_STORE_1.load(i).get1()); assertEquals(i, cache.get(i)); } }
Example #3
Source File: SimpleEh107ConfigTest.java From ehcache3 with Apache License 2.0 | 6 votes |
@Test public void testExpiryConfiguration() { final AtomicBoolean expiryCreated = new AtomicBoolean(false); MutableConfiguration<String, String> configuration = new MutableConfiguration<>(); configuration.setTypes(String.class, String.class); configuration.setExpiryPolicyFactory(() -> { expiryCreated.set(true); return new CreatedExpiryPolicy(Duration.FIVE_MINUTES); }); Cache<String, String> cache = cacheManager.createCache("cache", configuration); cache.putIfAbsent("42", "The Answer"); cache.putIfAbsent("42", "Or not!?"); assertThat(expiryCreated.get(), is(true)); }
Example #4
Source File: GridCacheTtlManagerEvictionSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration ccfg = new CacheConfiguration(DEFAULT_CACHE_NAME); ccfg.setCacheMode(cacheMode); ccfg.setEagerTtl(true); ccfg.setEvictionPolicy(new FifoEvictionPolicy(ENTRIES_LIMIT, 100)); ccfg.setOnheapCacheEnabled(true); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.HOURS, 12))); cfg.setCacheConfiguration(ccfg); return cfg; }
Example #5
Source File: GridCachePartitionEvictionDuringReadThroughSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration<Integer, Integer> ccfg = new CacheConfiguration<Integer, Integer>() .setName("config") .setAtomicityMode(CacheAtomicityMode.ATOMIC) .setBackups(0) // No need for backup, just load from the store if needed .setCacheStoreFactory(new CacheStoreFactory()) .setOnheapCacheEnabled(true) .setEvictionPolicy(new LruEvictionPolicy(100)) .setNearConfiguration(new NearCacheConfiguration<Integer, Integer>() .setNearEvictionPolicy(new LruEvictionPolicy<Integer, Integer>())); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 1))) .setReadThrough(true) .setWriteThrough(false); cfg.setCacheConfiguration(ccfg); return cfg; }
Example #6
Source File: AsyncMapImpl.java From vertx-ignite with Apache License 2.0 | 6 votes |
/** * @param ttl Time to live in ms. */ private <T> Future<T> executeWithTtl(Function<IgniteCache<K, V>, IgniteFuture<T>> cacheOp, long ttl) { ContextInternal ctx = vertx.getOrCreateContext(); Promise<T> promise = ctx.promise(); IgniteCache<K, V> cache0 = ttl > 0 ? cache.withExpiryPolicy(new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, ttl))) : cache; IgniteFuture<T> future = cacheOp.apply(cache0); future.listen(fut -> { try { promise.complete(unmarshal(future.get())); } catch (IgniteException e) { promise.fail(new VertxException(e)); } }); return promise.future(); }
Example #7
Source File: GridCacheTtlManagerNotificationTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override public void run() { try { barrier.await(); ExpiryPolicy plc1 = new CreatedExpiryPolicy(new Duration(MILLISECONDS, expirationDuration)); int keyStart = keysRangeGenerator.getAndIncrement() * cnt; for (int i = keyStart; i < keyStart + cnt; i++) cache.withExpiryPolicy(plc1).put("key" + i, 1); barrier.await(); } catch (Exception e) { throw new IgniteException(e); } }
Example #8
Source File: EhCache107ConfigurationIntegrationDocTest.java From ehcache3 with Apache License 2.0 | 6 votes |
@Test public void basicConfiguration() throws Exception { // tag::basicConfigurationExample[] CachingProvider provider = Caching.getCachingProvider(); // <1> CacheManager cacheManager = provider.getCacheManager(); // <2> MutableConfiguration<Long, String> configuration = new MutableConfiguration<Long, String>() // <3> .setTypes(Long.class, String.class) // <4> .setStoreByValue(false) // <5> .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE)); // <6> Cache<Long, String> cache = cacheManager.createCache("jCache", configuration); // <7> cache.put(1L, "one"); // <8> String value = cache.get(1L); // <9> // end::basicConfigurationExample[] assertThat(value, is("one")); }
Example #9
Source File: CacheExpiryTest.java From cache2k with Apache License 2.0 | 6 votes |
@Test public void testCacheStatisticsRemoveAllNoneExpired() throws Exception { ExpiryPolicy policy = new CreatedExpiryPolicy(Duration.ETERNAL); expiryPolicyServer.setExpiryPolicy(policy); MutableConfiguration<Integer, Integer> config = new MutableConfiguration<>(); config.setExpiryPolicyFactory(FactoryBuilder.factoryOf(expiryPolicyClient)) .setStatisticsEnabled(true); Cache<Integer, Integer> cache = getCacheManager().createCache(getTestCacheName(), config); for (int i = 0; i < 100; i++) { cache.put(i, i+100); } cache.removeAll(); assertEquals(100L, lookupManagementAttribute(cache, CacheStatistics, "CachePuts")); assertEquals(100L, lookupManagementAttribute(cache, CacheStatistics, "CacheRemovals")); }
Example #10
Source File: IgniteCacheWriteBehindNoUpdateSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String igniteInstanceName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(igniteInstanceName); CacheConfiguration<String, Long> ccfg = new CacheConfiguration<>(DEFAULT_CACHE_NAME); ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfg.setCacheMode(CacheMode.PARTITIONED); ccfg.setBackups(1); ccfg.setReadFromBackup(true); ccfg.setCopyOnRead(false); ccfg.setName(THROTTLES_CACHE_NAME); Duration expiryDuration = new Duration(TimeUnit.MINUTES, 1); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(expiryDuration)); ccfg.setReadThrough(false); ccfg.setWriteThrough(true); ccfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory<>(new TestCacheStore())); cfg.setCacheConfiguration(ccfg); return cfg; }
Example #11
Source File: ScanQueryOffheapExpiryPolicySelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { IgniteConfiguration cfg = super.getConfiguration(gridName); CacheConfiguration ccfg = defaultCacheConfiguration(); ccfg.setName(CACHE_NAME); ccfg.setAtomicityMode(CacheAtomicityMode.ATOMIC); ccfg.setCacheMode(CacheMode.PARTITIONED); ccfg.setBackups(1); ccfg.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.MINUTES, 10))); cfg.setCacheConfiguration(ccfg); return cfg; }
Example #12
Source File: CacheExpiryTest.java From cache2k with Apache License 2.0 | 6 votes |
@Test public void testCacheStatisticsRemoveAll() throws Exception { long _EXPIRY_MILLIS = 3; //cannot be zero or will not be added to the cache ExpiryPolicy policy = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, _EXPIRY_MILLIS)); expiryPolicyServer.setExpiryPolicy(policy); MutableConfiguration<Integer, Integer> config = new MutableConfiguration<>(); config.setExpiryPolicyFactory(FactoryBuilder.factoryOf(expiryPolicyClient)).setStatisticsEnabled(true); Cache<Integer, Integer> cache = getCacheManager().createCache(getTestCacheName(), config); for (int i = 0; i < 100; i++) { cache.put(i, i+100); } //should work with all implementations Thread.sleep(_EXPIRY_MILLIS); cache.removeAll(); assertEquals(100L, lookupManagementAttribute(cache, CacheStatistics, "CachePuts")); //Removals does not count expired entries assertEquals(0L, lookupManagementAttribute(cache, CacheStatistics, "CacheRemovals")); }
Example #13
Source File: Runner.java From ignite with Apache License 2.0 | 6 votes |
public static void main(String[] args) { ClientConnectorConfiguration connectorConfiguration = new ClientConnectorConfiguration().setPort(10890); TcpDiscoveryVmIpFinder ipFinder = new TcpDiscoveryVmIpFinder() .setAddresses(Collections.singleton("127.0.0.1:47500")); TcpDiscoverySpi discoSpi = new TcpDiscoverySpi() .setIpFinder(ipFinder) .setSocketTimeout(300) .setNetworkTimeout(300); CacheConfiguration expiryCacheCfg = new CacheConfiguration("twoSecondCache") .setExpiryPolicyFactory(FactoryBuilder.factoryOf( new CreatedExpiryPolicy(new Duration(TimeUnit.SECONDS, 2)))); IgniteConfiguration cfg = new IgniteConfiguration() .setClientConnectorConfiguration(connectorConfiguration) .setDiscoverySpi(discoSpi) .setCacheConfiguration(expiryCacheCfg) .setLocalHost("127.0.0.1"); Ignition.start(cfg); }
Example #14
Source File: IgniteCacheExpiryStoreLoadSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param async If {@code true} uses asynchronous method. * @throws Exception If failed. */ private void checkLocalLoad(boolean async) throws Exception { final IgniteCache<String, Integer> cache = jcache(0) .withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE))); List<Integer> keys = primaryKeys(cache, 3); if (async) cache.localLoadCacheAsync(null, keys.toArray(new Integer[3])).get(); else cache.localLoadCache(null, keys.toArray(new Integer[3])); assertEquals(3, cache.localSize()); boolean res = GridTestUtils.waitForCondition(new PA() { @Override public boolean apply() { return cache.localSize() == 0; } }, TIME_TO_LIVE + WAIT_TIME); assertTrue(res); }
Example #15
Source File: IgniteCacheExpiryStoreLoadSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @param async If {@code true} uses asynchronous method. * @throws Exception If failed. */ private void checkLoad(boolean async) throws Exception { IgniteCache<String, Integer> cache = jcache(0) .withExpiryPolicy(new CreatedExpiryPolicy(new Duration(MILLISECONDS, TIME_TO_LIVE))); List<Integer> keys = new ArrayList<>(); keys.add(primaryKey(jcache(0))); keys.add(primaryKey(jcache(1))); keys.add(primaryKey(jcache(2))); if (async) cache.loadCacheAsync(null, keys.toArray(new Integer[3])).get(); else cache.loadCache(null, keys.toArray(new Integer[3])); assertEquals(3, cache.size(CachePeekMode.PRIMARY)); Thread.sleep(TIME_TO_LIVE + WAIT_TIME); assertEquals(0, cache.size()); }
Example #16
Source File: JCacheTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testExpiration() throws InterruptedException, IllegalArgumentException, URISyntaxException, FailedToStartRedisException, IOException { RedisProcess runner = new RedisRunner() .nosave() .randomDir() .port(6311) .run(); MutableConfiguration<String, String> config = new MutableConfiguration<>(); config.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1))); config.setStoreByValue(true); URI configUri = getClass().getResource("redisson-jcache.json").toURI(); Cache<String, String> cache = Caching.getCachingProvider().getCacheManager(configUri, null) .createCache("test", config); CountDownLatch latch = new CountDownLatch(1); String key = "123"; ExpiredListener clientListener = new ExpiredListener(latch, key, "90"); MutableCacheEntryListenerConfiguration<String, String> listenerConfiguration = new MutableCacheEntryListenerConfiguration<String, String>(FactoryBuilder.factoryOf(clientListener), null, true, true); cache.registerCacheEntryListener(listenerConfiguration); cache.put(key, "90"); Assert.assertNotNull(cache.get(key)); latch.await(); Assert.assertNull(cache.get(key)); cache.close(); runner.stop(); }
Example #17
Source File: OpenJPAJCacheDataCacheManager.java From commons-jcs with Apache License 2.0 | 5 votes |
Cache<Object, Object> getOrCreateCache(final String prefix, final String entity) { final String internalName = prefix + entity; Cache<Object, Object> cache = cacheManager.getCache(internalName); if (cache == null) { final Properties properties = cacheManager.getProperties(); final MutableConfiguration<Object, Object> configuration = new MutableConfiguration<Object, Object>() .setStoreByValue("true".equalsIgnoreCase(properties.getProperty("jcache.store-by-value", "false"))); configuration.setReadThrough("true".equals(properties.getProperty("jcache.read-through", "false"))); configuration.setWriteThrough("true".equals(properties.getProperty("jcache.write-through", "false"))); if (configuration.isReadThrough()) { configuration.setCacheLoaderFactory(new FactoryBuilder.ClassFactory<CacheLoader<Object, Object>>(properties.getProperty("jcache.cache-loader-factory"))); } if (configuration.isWriteThrough()) { configuration.setCacheWriterFactory(new FactoryBuilder.ClassFactory<CacheWriter<Object, Object>>(properties.getProperty("jcache.cache-writer-factory"))); } final String expirtyPolicy = properties.getProperty("jcache.expiry-policy-factory"); if (expirtyPolicy != null) { configuration.setExpiryPolicyFactory(new FactoryBuilder.ClassFactory<ExpiryPolicy>(expirtyPolicy)); } else { configuration.setExpiryPolicyFactory(new FactoryBuilder.SingletonFactory<ExpiryPolicy>(new CreatedExpiryPolicy(Duration.FIVE_MINUTES))); } configuration.setManagementEnabled("true".equals(properties.getProperty("jcache.management-enabled", "false"))); configuration.setStatisticsEnabled("true".equals(properties.getProperty("jcache.statistics-enabled", "false"))); cache = cacheManager.createCache(internalName, configuration); } return cache; }
Example #18
Source File: CacheConfig.java From ignite with Apache License 2.0 | 5 votes |
/** * Configure streaming cache. */ public static CacheConfiguration<AffinityUuid, String> wordCache() { CacheConfiguration<AffinityUuid, String> cfg = new CacheConfiguration<>("words"); // Index all words streamed into cache. cfg.setIndexedTypes(AffinityUuid.class, String.class); // Sliding window of 1 seconds. cfg.setExpiryPolicyFactory(FactoryBuilder.factoryOf(new CreatedExpiryPolicy(new Duration(SECONDS, 1)))); return cfg; }
Example #19
Source File: JCacheTest.java From redisson with Apache License 2.0 | 5 votes |
@Test public void testCreatedExpiryPolicy() throws Exception { RedisProcess runner = new RedisRunner() .nosave() .randomDir() .port(6311) .run(); URL configUrl = getClass().getResource("redisson-jcache.json"); Config cfg = Config.fromJSON(configUrl); MutableConfiguration c = new MutableConfiguration(); c.setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(new Duration(MILLISECONDS, 500))); Configuration<String, String> config = RedissonConfiguration.fromConfig(cfg, c); Cache<String, String> cache = Caching.getCachingProvider().getCacheManager() .createCache("test", config); cache.put("1", "2"); Thread.sleep(500); assertThat(cache.get("1")).isNull(); cache.put("1", "3"); assertThat(cache.get("1")).isEqualTo("3"); Thread.sleep(500); assertThat(cache.get("1")).isNull(); cache.put("1", "4"); assertThat(cache.get("1")).isEqualTo("4"); Thread.sleep(100); cache.put("1", "5"); assertThat(cache.get("1")).isEqualTo("5"); cache.close(); runner.stop(); }
Example #20
Source File: Eh107XmlIntegrationTest.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void test107ExpiryOverriddenByEhcacheTemplateExpiry() { final AtomicBoolean expiryFactoryInvoked = new AtomicBoolean(false); MutableConfiguration<Long, Product> configuration = new MutableConfiguration<>(); configuration.setTypes(Long.class, Product.class); configuration.setExpiryPolicyFactory(() -> { expiryFactoryInvoked.set(true); return new CreatedExpiryPolicy(Duration.FIVE_MINUTES); }); cacheManager.createCache("productCache3", configuration); assertThat(expiryFactoryInvoked.get(), is(false)); }
Example #21
Source File: ConfigurationMergerTest.java From ehcache3 with Apache License 2.0 | 5 votes |
@Test public void jsr107ExpiryGetsRegistered() { MutableConfiguration<Object, Object> configuration = new MutableConfiguration<>(); RecordingFactory<CreatedExpiryPolicy> factory = factoryOf(new CreatedExpiryPolicy(javax.cache.expiry.Duration.FIVE_MINUTES)); configuration.setExpiryPolicyFactory(factory); ConfigurationMerger.ConfigHolder<Object, Object> configHolder = merger.mergeConfigurations("Cache", configuration); assertThat(factory.called, is(true)); org.ehcache.expiry.ExpiryPolicy<Object, Object> resourcesExpiry = configHolder.cacheResources.getExpiryPolicy(); org.ehcache.expiry.ExpiryPolicy<Object, Object> configExpiry = configHolder.cacheConfiguration.getExpiryPolicy(); assertThat(configExpiry, sameInstance(resourcesExpiry)); }
Example #22
Source File: JCacheCreationExpiryTest.java From caffeine with Apache License 2.0 | 5 votes |
@Override protected CaffeineConfiguration<Integer, Integer> getConfiguration() { CaffeineConfiguration<Integer, Integer> configuration = new CaffeineConfiguration<>(); configuration.setExpiryPolicyFactory(() -> new CreatedExpiryPolicy( new Duration(TimeUnit.MILLISECONDS, EXPIRY_DURATION))); configuration.setTickerFactory(() -> ticker::read); return configuration; }
Example #23
Source File: EntryProcessorTest.java From caffeine with Apache License 2.0 | 5 votes |
@Override protected CaffeineConfiguration<Integer, Integer> getConfiguration() { CaffeineConfiguration<Integer, Integer> config = new CaffeineConfiguration<>(); config.setExpiryPolicyFactory(() -> new CreatedExpiryPolicy(Duration.FIVE_MINUTES)); config.setCacheLoaderFactory(MapLoader::new); config.setCacheWriterFactory(MapWriter::new); config.setTickerFactory(() -> ticker::read); config.setMaximumSize(OptionalLong.of(200)); config.setWriteThrough(true); config.setReadThrough(true); return config; }
Example #24
Source File: TestJCache.java From jframe with Apache License 2.0 | 5 votes |
@Test public void createCacheTest() { CachingProvider provider = Caching.getCachingProvider(); CacheManager cacheManager = provider.getCacheManager(); MutableConfiguration<Long, String> configuration = new MutableConfiguration<Long, String>() .setTypes(Long.class, String.class).setStoreByValue(false) .setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.ONE_MINUTE)); Cache<Long, String> cache = cacheManager.createCache("jCache", configuration); cache.put(1L, "one"); String value = cache.get(1L); LOG.info(value); }
Example #25
Source File: InitializrAutoConfiguration.java From initializr with Apache License 2.0 | 5 votes |
@Bean JCacheManagerCustomizer initializrCacheManagerCustomizer() { return (cacheManager) -> { cacheManager.createCache("initializr.metadata", config().setExpiryPolicyFactory(CreatedExpiryPolicy.factoryOf(Duration.TEN_MINUTES))); cacheManager.createCache("initializr.dependency-metadata", config()); cacheManager.createCache("initializr.project-resources", config()); cacheManager.createCache("initializr.templates", config()); }; }
Example #26
Source File: IgniteCacheExpiryPolicyAbstractTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @throws Exception If failed. */ @Test public void testZeroOnCreate() throws Exception { factory = CreatedExpiryPolicy.factoryOf(Duration.ZERO); startGrids(); for (final Integer key : keys()) { log.info("Test zero duration on create, key: " + key); zeroOnCreate(key); } }
Example #27
Source File: ImmediateExpiryTest.java From commons-jcs with Apache License 2.0 | 5 votes |
@Test public void immediate() { final CachingProvider cachingProvider = Caching.getCachingProvider(); final CacheManager cacheManager = cachingProvider.getCacheManager(); cacheManager.createCache("default", new MutableConfiguration<>() .setExpiryPolicyFactory( new FactoryBuilder.SingletonFactory<ExpiryPolicy>(new CreatedExpiryPolicy(Duration.ZERO)))); final Cache<String, String> cache = cacheManager.getCache("default"); assertFalse(cache.containsKey("foo")); cache.put("foo", "bar"); assertFalse(cache.containsKey("foo")); cachingProvider.close(); }
Example #28
Source File: H2RowExpireTimeIndexSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Put values into the table with expire policy. * * @param cache cache to put values in. * @param key key of the row. * @param val value of the row. */ private void putExpireInYear(IgniteCache cache, Integer key, Integer val) { CreatedExpiryPolicy expireSinceCreated = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, TimeUnit.DAYS.toMillis(365))); IgniteCache<Integer, Integer> expCache = cache.withExpiryPolicy(expireSinceCreated); expCache.put(key, val); }
Example #29
Source File: H2RowExpireTimeIndexSelfTest.java From ignite with Apache License 2.0 | 5 votes |
/** * Put values into the table with expire policy. Inserted row become expired in {@link #EXPIRE_IN_MS_FROM_CREATE} * milliseconds. * * @param cache cache to put values in. * @param key key of the row. * @param val value of the row. */ private void putExpiredSoon(IgniteCache cache, Integer key, Integer val) { CreatedExpiryPolicy expireSinceCreated = new CreatedExpiryPolicy(new Duration(TimeUnit.MILLISECONDS, EXPIRE_IN_MS_FROM_CREATE)); IgniteCache<Integer, Integer> expCache = cache.withExpiryPolicy(expireSinceCreated); expCache.put(key, val); }
Example #30
Source File: BlobStoreGroup.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private MutableConfiguration<BlobId, String> getCacheConfiguration() { return new MutableConfiguration<BlobId, String>() .setStoreByValue(false) .setExpiryPolicyFactory( CreatedExpiryPolicy.factoryOf(new Duration(blobIdCacheTimeout.unit(), blobIdCacheTimeout.value())) ) .setManagementEnabled(true) .setStatisticsEnabled(true); }