Java Code Examples for org.cache2k.Cache#replaceIfEquals()
The following examples show how to use
org.cache2k.Cache#replaceIfEquals() .
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: AllMutatorsExpireTest.java From cache2k with Apache License 2.0 | 4 votes |
int mutate(final int variant, final Cache<Integer, Integer> c) { int opCnt = 1; switch (variant) { case 0: c.put(KEY, VALUE); break; case 1: c.putIfAbsent(KEY, VALUE); break; case 2: c.peekAndPut(KEY, VALUE); break; case 3: c.put(1,1); c.peekAndReplace(KEY, VALUE); opCnt++; break; case 4: c.put(KEY, VALUE); c.replace(KEY, VALUE); opCnt++; break; case 5: c.put(KEY, VALUE); c.replaceIfEquals(KEY, VALUE, VALUE); opCnt++; break; case 6: c.invoke(KEY, new EntryProcessor<Integer, Integer, Object>() { @Override public Object process(final MutableCacheEntry<Integer, Integer> e) throws Exception { e.setValue(VALUE); return null; } }); break; case 7: c.put(KEY, VALUE); c.put(KEY, VALUE); opCnt++; break; } return opCnt; }
Example 2
Source File: RejectNullValueTest.java From cache2k with Apache License 2.0 | 4 votes |
@Test(expected = NullPointerException.class) public void replaceIfEquals() { Cache<Integer, Integer> c = target.cache(); c.put(KEY, VALUE); c.replaceIfEquals(KEY, VALUE, null); }