Java Code Examples for javax.cache.expiry.CreatedExpiryPolicy#factoryOf()
The following examples show how to use
javax.cache.expiry.CreatedExpiryPolicy#factoryOf() .
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: 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 2
Source File: IgniteCacheExpiryPolicyAbstractTest.java From ignite with Apache License 2.0 | 3 votes |
/** * Put entry to server node and check how its expires in client NearCache. * * @throws Exception If failed. */ @Test public void testNearExpiresOnClient() throws Exception { if (cacheMode() != PARTITIONED) return; factory = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 2)); nearCache = true; startGrids(); IgniteConfiguration clientCfg = getConfiguration("client"); ((TcpDiscoverySpi)clientCfg.getDiscoverySpi()).setForceServerMode(false); Ignite client = startClientGrid("client", clientCfg); IgniteCache<Object, Object> cache = client.cache(DEFAULT_CACHE_NAME); Integer key = 1; // Put on server node. jcache(0).put(key, 1); // Make entry cached in client NearCache. assertEquals(1, cache.get(key)); assertEquals(1, cache.localPeek(key, CachePeekMode.NEAR)); waitExpired(key); // Check client NearCache. assertNull(cache.localPeek(key, CachePeekMode.NEAR)); }
Example 3
Source File: IgniteCacheExpiryPolicyAbstractTest.java From ignite with Apache License 2.0 | 2 votes |
/** * @throws Exception If failed. */ @Test public void testNearExpiresWithCacheStore() throws Exception { if (cacheMode() != PARTITIONED) return; factory = CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1)); nearCache = true; startGridsMultiThreaded(gridCount()); IgniteConfiguration clientCfg = getConfiguration("client"); ((TcpDiscoverySpi)clientCfg.getDiscoverySpi()).setForceServerMode(false); Ignite client = startClientGrid("client", clientCfg); CacheConfiguration ccfg = cacheConfiguration("testCache"); ccfg.setCacheStoreFactory(FactoryBuilder.factoryOf(GridCacheTestStore.class)); // ccfg.setExpiryPolicyFactory( CreatedExpiryPolicy.factoryOf(new Duration(TimeUnit.SECONDS, 1))); IgniteCache<Object, Object> cache = client.getOrCreateCache(ccfg); Integer key = 1; cache.put(key, 1); // Make entry cached in client NearCache. assertEquals(1, cache.get(key)); assertEquals(1, cache.localPeek(key, CachePeekMode.NEAR)); waitExpired(key); for (int i = 0; i < gridCount(); i++) assertNull(jcache(i).localPeek(key, CachePeekMode.BACKUP, CachePeekMode.PRIMARY)); assertEquals(null, cache.get(key)); }