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

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

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

Cache.putAll介绍

暂无

代码示例

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

@Override
  <K, V> void put(K key, V value, Cache<K, V> cache) {
   Map<K, V> map = new HashMap<>();
   map.put(key, value);
   cache.putAll(map);
  }
};

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

public void testRemoveIfMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Collection<Object> keys = cache.keySet();
 keys.removeIf(k -> k.equals("2"));
 assertCacheSize(2);
}

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

public void testRemoveIfMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Collection<Object> values = cache.values();
 values.removeIf(v -> ((String) v).startsWith("t"));
 assertCacheSize(1);
}

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

public void testClearMethodOfEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Set<Map.Entry<Object, Object>> entries = cache.entrySet();
 entries.clear();
 assertCacheIsEmpty();
}

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

public void testRemoveIfMethodOfEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Set<Map.Entry<Object, Object>> entries = cache.entrySet();
 entries.removeIf(e -> ((String) e.getValue()).startsWith("t"));
 assertCacheSize(1);
}

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

@Test(expectedExceptions = UnsupportedOperationException.class)
public void testAddMethodsForEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Set<Map.Entry<Object, Object>> entries = cache.entrySet();
 entries.add(createMapEntry("4", "four"));
}

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

public void testClearMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Set<Object> keys = cache.keySet();
 keys.clear();
 assertCacheIsEmpty();
}

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

public void testRemoveAllMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<String> keyCollection = new ArrayList<>(2);
 keyCollection.add(key2);
 keyCollection.add(key3);
 Collection<Object> keys = cache.keySet();
 keys.removeAll(keyCollection);
 assertCacheSize(1);
}

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

public void testClearMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 Collection<Object> values = cache.values();
 values.clear();
 assertCacheIsEmpty();
}

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

public void testRetainAllMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<String> keyCollection = new ArrayList<>(2);
 keyCollection.add(key2);
 keyCollection.add(key3);
 keyCollection.add("6");
 Collection<Object> keys = cache.keySet();
 keys.retainAll(keyCollection);
 assertCacheSize(2);
}

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

public void testRetainAllMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<String> valueCollection = new ArrayList<>(2);
 valueCollection.add(value1);
 valueCollection.add(value2);
 valueCollection.add("5");
 Collection<Object> values = cache.values();
 values.retainAll(valueCollection);
 assertCacheSize(2);
}

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

public void testRemoveAllMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<String> valueCollection = new ArrayList<>(2);
 valueCollection.add(value1);
 valueCollection.add(value2);
 Collection<Object> values = cache.values();
 values.removeAll(valueCollection);
 assertCacheSize(1);
}

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

@Test(expectedExceptions = UnsupportedOperationException.class)
public void testAddMethodsForEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache(0, "replSync").putAll(m);
 Set<Map.Entry<Object, Object>> entries = cache(0, "replSync").entrySet();
 entries.add(createMapEntry("4", "four"));
}

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

public void testPutMap() throws Exception {
 Matcher<FlagAffectedCommand> matcher = getFlagMatcher();
 Map<Object, Object> data = new HashMap<Object, Object>();
 data.put("key", "value");
 data.put("key2", "value2");
 cache.putAll(data);
 expectSingleEntryCreated(cache, "key", "value", matcher);
 expectSingleEntryCreated(cache, "key2", "value2", matcher);
}

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

public void testRemoveAllMethodOfEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<Map.Entry> entryCollection = new ArrayList<>(2);
 entryCollection.add(createMapEntry(key1, value1));
 entryCollection.add(createMapEntry(key3, value3));
 Set<Map.Entry<Object, Object>> entries = cache.entrySet();
 entries.removeAll(entryCollection);
 assertCacheSize(1);
}

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

public void testRetainAllMethodOfEntryCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache.putAll(m);
 List<Map.Entry> entryCollection = new ArrayList<>(3);
 entryCollection.add(createMapEntry(key1, value1));
 entryCollection.add(createMapEntry(key3, value3));
 entryCollection.add(createMapEntry("4", "5"));
 Set<Map.Entry<Object, Object>> entries = cache.entrySet();
 entries.retainAll(entryCollection);
 assertCacheSize(2);
}

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

public void testRetainAllMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache(0, "replSync").putAll(m);
 List<String> keyCollection = new ArrayList<>(2);
 keyCollection.add(key2);
 keyCollection.add(key3);
 keyCollection.add("6");
 Collection<Object> keys = cache(0, "replSync").keySet();
 keys.retainAll(keyCollection);
 assertEquals(2, cache(0, "replSync").size());
}

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

public void testRemoveAllMethodOfKeyCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache(0, "replSync").putAll(m);
 List<String> keyCollection = new ArrayList<>(2);
 keyCollection.add(key2);
 keyCollection.add(key3);
 Collection<Object> keys = cache(0, "replSync").keySet();
 keys.removeAll(keyCollection);
 assertEquals(1, cache(0, "replSync").size());
}

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

public void testRemoveAllMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache(0, "replSync").putAll(m);
 List<String> valueCollection = new ArrayList<>(2);
 valueCollection.add(value1);
 valueCollection.add(value2);
 Collection<Object> values = cache(0, "replSync").values();
 values.removeAll(valueCollection);
 assertEquals(1, cache(0, "replSync").size());
}

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

public void testRetainAllMethodOfValuesCollection() {
 final String key1 = "1", value1 = "one", key2 = "2", value2 = "two", key3 = "3", value3 = "three";
 Map<String, String> m = new HashMap<>();
 m.put(key1, value1);
 m.put(key2, value2);
 m.put(key3, value3);
 cache(0, "replSync").putAll(m);
 List<String> valueCollection = new ArrayList<>(2);
 valueCollection.add(value1);
 valueCollection.add(value2);
 valueCollection.add("5");
 Collection<Object> values = cache(0, "replSync").values();
 values.retainAll(valueCollection);
 assertEquals(2, cache(0, "replSync").size());
}

相关文章