org.infinispan.Cache.merge()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(138)

本文整理了Java中org.infinispan.Cache.merge()方法的一些代码示例,展示了Cache.merge()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.merge()方法的具体详情如下:
包路径:org.infinispan.Cache
类名称:Cache
方法名:merge

Cache.merge介绍

暂无

代码示例

代码示例来源:origin: org.infinispan/infinispan-core

@SuppressWarnings("ConstantConditions")
public void testMergeNullParameters() {
 expectException(NullPointerException.class, "Null keys are not supported!",
    () -> cache.merge(null, "X", (o, o2) -> "Y"));
 expectException(NullPointerException.class, "Null values are not supported!",
    () -> cache.merge("k", null, (o, o2) -> "Y"));
 expectException(NullPointerException.class, "Null functions are not supported!",
    () -> cache.merge("k", "X", null));
}

代码示例来源:origin: org.infinispan/infinispan-query

@Test(enabled = false, description = "ISPN-7590")
public void testMergeRemove() {
 test(c -> c.merge(KEY, FLUFFY, (o, n) -> null), sm -> {});
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testMergeRemove() {
 test(c -> c.merge(KEY, FLUFFY, (o, n) -> null), sm -> {}, true);
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testMerge() {
 test(c -> c.merge(KEY, FLUFFY, (o, n) -> n), this::assertFluffyIndexed);
}

代码示例来源:origin: org.infinispan/infinispan-query

public void testMerge() {
 test(c -> c.merge(KEY, FLUFFY, (o, n) -> n), this::assertFluffyIndexed, false);
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMerge() {
 cache.put("A", "B");
 // replace
 cache.merge("A", "C", (oldValue, newValue) -> "" + oldValue + newValue);
 assertEquals("BC", cache.get("A"));
 // remove if null value after remapping
 cache.merge("A", "C", (oldValue, newValue) -> null);
 assertEquals(null, cache.get("A"));
 // put if absent
 cache.merge("F", "42", (oldValue, newValue) -> "" + oldValue + newValue);
 assertEquals("42", cache.get("F"));
 cache.put("A", "B");
 RuntimeException mergeRaisedException = new RuntimeException("hi there");
 expectException(RuntimeException.class, "hi there", () -> cache.merge("A", "C", (k, v) -> {
   throw mergeRaisedException;
 }));
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMerge() throws Exception {
 cache.put("A", "B");
 // replace
 cache.merge("A", "C", (oldValue, newValue) -> "" + oldValue + newValue);
 assertEquals("BC", cache.get("A"));
 // remove if null value after remapping
 cache.merge("A", "C", (oldValue, newValue) -> null);
 assertEquals(null, cache.get("A"));
 // put if absent
 cache.merge("F", "42", (oldValue, newValue) -> "" + oldValue + newValue);
 assertEquals("42", cache.get("F"));
 cache.put("A", "B");
 RuntimeException mergeRaisedException = new RuntimeException("hi there");
 expectException(RuntimeException.class, "hi there", () -> cache.merge("A", "C", (k, v) -> {
   throw mergeRaisedException;
 }));
}

代码示例来源:origin: org.infinispan/infinispan-core

public void testMergeFromNonOwner() {
   initAndTest();

   // exception raised by the user
   RuntimeException mergeException = new RuntimeException("hi there");
   expectException(RemoteException.class, () -> getFirstNonOwner("k1").merge("k1", "ex", (k, v) -> {
     throw mergeException;
   }));
   asyncWaitOnPrimary("k1", ReadWriteKeyCommand.class);
   assertOnAllCachesAndOwnership("k1", "value");

   // merge function applied
   Object retval = getFirstNonOwner("k1").merge("k1", "value2", (v1, v2) -> "merged_" + v1 + "_" + v2);
   asyncWait("k1", ReadWriteKeyCommand.class);
   if (testRetVals) assertEquals("merged_value_value2", retval);
   assertOnAllCachesAndOwnership("k1", "merged_value_value2");

   // remove when null
   retval = getFirstNonOwner("k1").merge("k1", "valueRem", (v1, v2) -> null);
   asyncWait("k1", ReadWriteKeyCommand.class);
   if (testRetVals) assertNull(retval);
   assertRemovedOnAllCaches("k1");

   // put if absent
   retval = getFirstNonOwner("notThere").merge("notThere", "value2", (v1, v2) -> "merged_" + v1 + "_" + v2);
   asyncWait("notThere", ReadWriteKeyCommand.class);
   if (testRetVals) assertEquals("value2", retval);
   assertOnAllCachesAndOwnership("notThere", "value2");
  }
}

代码示例来源:origin: org.infinispan/infinispan-core

(BiConsumer<Cache<Object, Object>, CacheEntry<Object, Object>>) (c, e) -> c.merge(e.getKey(), "-other", (v1, v2) -> "" + v1 + v2)
}).flatMap(consumer ->
  Stream.of(Boolean.TRUE, Boolean.FALSE).map(bool -> new Object[] { consumer, bool })

代码示例来源:origin: org.infinispan/infinispan-core

assertEquals("ab", this.<Object, String>cache(2, cacheName).merge(key, "b", (o, n) -> o + n));
assertLocalValue(0, key, "ab");
assertLocalValue(1, key, "a");
assertEquals("abc", this.<Object, String>cache(0, cacheName).merge(key, "c", (o, n) -> o + n));
assertLocalValue(0, key, "abc");
assertEquals(null, cache(1, cacheName).merge(key, "x", (o, n) -> "abc".equals(o) ? null : "unexpected"));
assertLocalValue(0, key, null);
assertLocalValue(1, key, null);
assertEquals("x", cache(1, cacheName).merge(otherKey, "x", (o, n) -> "unexpected"));
assertLocalValue(0, otherKey, "x");
assertLocalValue(1, otherKey, "x");
assertEquals(null, cache(0, cacheName).merge(otherKey, "y", (o, n) -> "x".equals(o) ? null : "unexpected"));
assertLocalValue(0, otherKey, null);
assertOwnershipAndNonOwnership(otherKey, false);
assertEquals("z", cache(0, cacheName).merge(otherKey, "z", (o, n) -> "unexpected"));
assertLocalValue(0, otherKey, "z");
assertOwnershipAndNonOwnership(otherKey, false);

代码示例来源:origin: org.infinispan/infinispan-query

cache2.merge(key, person4, (k1, v3) -> new Person(key, "eats something", 42));
if (transactionsEnabled()) transactionManager.commit();
StaticTestingErrorHandler.assertAllGood(cache1, cache2);
cache2.merge(key, new Person(key, "hola", 42),
   (v1, v2) -> new Person(v1.getName() + "_" + v2.getName(), v1.getBlurb() + "_" + v2.getBlurb(), v1.getAge() + v2.getAge()));
if (transactionsEnabled()) transactionManager.commit();
cache2.merge(key, person4, (k, v) -> null);
if (transactionsEnabled()) transactionManager.commit();
StaticTestingErrorHandler.assertAllGood(cache1, cache2);

相关文章