Java Code Examples for org.apache.ignite.IgniteCache#getAndPutAsync()
The following examples show how to use
org.apache.ignite.IgniteCache#getAndPutAsync() .
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: IgniteCacheConfigVariationsFullApiTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception In case of error. */ @Test public void testGetAndPutAsync() throws Exception { IgniteCache<String, Integer> cache = jcache(); cache.put("key1", 1); cache.put("key2", 2); IgniteFuture<Integer> fut1 = cache.getAndPutAsync("key1", 10); IgniteFuture<Integer> fut2 = cache.getAndPutAsync("key2", 11); assertEquals((Integer)1, fut1.get(5000)); assertEquals((Integer)2, fut2.get(5000)); assertEquals((Integer)10, cache.get("key1")); assertEquals((Integer)11, cache.get("key2")); }
Example 2
Source File: GridCacheAbstractFullApiSelfTest.java From ignite with Apache License 2.0 | 6 votes |
/** * @throws Exception In case of error. */ @Test public void testGetAndPutAsync() throws Exception { IgniteCache<String, Integer> cache = jcache(); cache.put("key1", 1); cache.put("key2", 2); IgniteFuture<Integer> fut1 = cache.getAndPutAsync("key1", 10); IgniteFuture<Integer> fut2 = cache.getAndPutAsync("key2", 11); assertEquals((Integer)1, fut1.get(5000)); assertEquals((Integer)2, fut2.get(5000)); assertEquals((Integer)10, cache.get("key1")); assertEquals((Integer)11, cache.get("key2")); }
Example 3
Source File: CacheAsyncOperationsTest.java From ignite with Apache License 2.0 | 5 votes |
/** * @param cache Cache. */ private void async1(IgniteCache<Integer, Integer> cache) { cache.put(1, 1); latch = new CountDownLatch(1); IgniteFuture<?> fut1 = cache.putAsync(0, 0); IgniteFuture<?> fut2 = cache.getAndPutAsync(1, 2); IgniteFuture<?> fut3 = cache.getAndPutAsync(1, 3); assertFalse(fut1.isDone()); assertFalse(fut2.isDone()); assertFalse(fut3.isDone()); latch.countDown(); try { fut1.get(); fail(); } catch (CacheException e) { log.info("Expected error: " + e); } assertEquals(1, fut2.get()); assertEquals(2, fut3.get()); assertNull(cache.get(0)); assertEquals((Integer)3, cache.get(1)); }