@Test public void testPutIfAbsent() throws Exception { String key = "key"; String expected = "value"; assertNull(springCache.putIfAbsent(key, expected)); assertEquals(expected, springCache.putIfAbsent(key, "wrongValue").get()); assertEquals(expected, springCache.get(key).get()); }
@Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; }
SpringCache implements Cache { @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; } }
SpringCache implements Cache { @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; } SpringCache(IgniteCache<Object, Object> cache, SpringCacheManager mgr); }
SpringCache implements Cache { @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; } SpringCache(IgniteCache<Object, Object> cache, SpringCacheManager mgr); @Override String getName(); @Override Object getNativeCache(); @Override ValueWrapper get(Object key); @SuppressWarnings("unchecked") @Override T get(Object key, Class<T> type); @SuppressWarnings("unchecked") @Override T get(final Object key, final Callable<T> valLdr); @Override void put(Object key, Object val); @Override ValueWrapper putIfAbsent(Object key, Object val); @Override void evict(Object key); @Override void clear(); }
SpringCache implements Cache { @Override public ValueWrapper putIfAbsent(Object key, Object val) { Object old; if (val == null) old = cache.withSkipStore().getAndPutIfAbsent(key, NULL); else old = cache.getAndPutIfAbsent(key, val); return old != null ? fromValue(old) : null; } SpringCache(IgniteCache<Object, Object> cache, SpringCacheManager mgr); @Override String getName(); @Override Object getNativeCache(); @Override ValueWrapper get(Object key); @SuppressWarnings("unchecked") @Override T get(Object key, Class<T> type); @SuppressWarnings("unchecked") @Override T get(final Object key, final Callable<T> valLdr); @Override void put(Object key, Object val); @Override ValueWrapper putIfAbsent(Object key, Object val); @Override void evict(Object key); @Override void clear();  }