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

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

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

Cache.values介绍

暂无

代码示例

代码示例来源:origin: jottinger/ci-bayes

int totalCount() {
  int sum = 0;
  for (Integer i : categories.values()) {
    sum += i;
  }
  return sum;
}

代码示例来源:origin: infinispan/infinispan-simple-tutorials

public static void main(String[] args) {
  ApplicationContext ctx = SpringApplication.run(SpringBootApp.class, args);
  EmbeddedCacheManager cacheManager = ctx.getBean(EmbeddedCacheManager.class);
  Cache<Long, String> cache = cacheManager.getCache(CACHE_NAME);
  cache.put(System.currentTimeMillis(), "Infinispan");
  logger.info("Keys from Cache: {}", cache.keySet());
  logger.info("Values from Cache: {}", cache.values());
}

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

private List<String> copyValues(Cache<?, String> cache) {
 return new ArrayList<>(cache.values());
}

代码示例来源:origin: org.restcomm.cluster/cache

@SuppressWarnings({ "rawtypes", "unchecked" })
public Set getAllValues() {
  CloseableIterator<Object> values = getJBossCache().values().iterator();
  Set output = new HashSet();
  while (values.hasNext()) {
    output.add(values.next());
  }
  return output;
}

代码示例来源: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 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 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 testObjValuesMax() {
 Cache<Integer, String> cache = getCache(0);
 int range = 10;
 // First populate the cache with a bunch of values
 IntStream.range(0, range).boxed().forEach(i -> cache.put(i, i + "-value"));
 assertEquals(range, cache.size());
 CacheCollection<String> keySet = cache.values();
 assertEquals("9-value",
    createStream(keySet).max((e1, e2) -> Integer.compare(
       Integer.valueOf(e1.substring(0, 1)),
       Integer.valueOf(e2.substring(0, 1)))).get());
}

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

public void testValuesForEachNonSerializable() {
   assertEquals(0, cache.size());
   cache.put("k1", "v1");

   List<Object> values = new ArrayList<>();
   cache.values().forEach(values::add);

   assertEquals(1, values.size());
   assertEquals("v1", values.iterator().next());
  }
}

代码示例来源: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(0, "replSync").putAll(m);
 Collection<Object> values = cache(0, "replSync").values();
 values.clear();
 assertEquals(0, cache(0, "replSync").size());
}

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

public void testValuesIsEmptyAfterLocalClear() throws Exception {
 cache.put(1, "v1");
 tm().begin();
 try {
   cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).clear();
   assertTrue(cache.values().isEmpty());
 } finally {
   tm().commit();
 }
}

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

public void testTxCleanupWithValues() throws Exception {
 tm().begin();
 assertEquals(0, cache.values().size());
 TransactionTable txTable = getTransactionTable(cache);
 assertEquals(1, txTable.getLocalTransactions().size());
 tm().commit();
 assertEquals(0, txTable.getLocalTransactions().size());
}

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

public void testValuesAfterClearInBranchedTransaction() throws Exception {
 cache.put(1, "v1");
 tm().begin();
 try {
 assertEquals("v1", cache.get(1));
 //clear is non transactional
 cache.clear();
 Collection<Object> values = cache.values();
 assertEquals(1, values.size());
 assertTrue(values.contains("v1"));
 } finally {
   safeCommit(false);
 }
}

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

public void testValuesAfterClearInBranchedTransactionOnWrite() throws Exception {
 cache.put(1, "v1");
 tm().begin();
 try {
 assertEquals("v1", cache.put(1, "v2"));
 //clear is non transactional
 cache.clear();
 Collection<Object> values = cache.values();
 assertEquals(1, values.size());
 assertTrue(values.contains("v2"));
 } finally {
   safeCommit(true);
 }
}

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

public void testValuesSizeAfterLocalClear() throws Exception {
   cache.put(1, "v1");
   tm().begin();
   try {
     cache.getAdvancedCache().withFlags(Flag.CACHE_MODE_LOCAL).clear();
     assertEquals(0, cache.values().size());
   } finally {
     tm().commit();
   }
  }
}

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

public void testObjValuesForEachCacheInjected() {
 Cache<Integer, String> cache = getCache(0);
 int cacheOffset = populateNextForEachStructure(cache);
 int atomicOffset = populateNextForEachStructure(new AtomicInteger());
 try {
   testIntOperation(() -> {
    createStream(cache.values()).forEach(new ForEachInjected<>(cacheOffset, atomicOffset,
       e -> Integer.valueOf(e.substring(0, 1))));
    return ((AtomicInteger) getForEachObject(atomicOffset)).get();
   }, cache);
 } finally {
   clearForEachObject(cacheOffset);
   clearForEachObject(atomicOffset);
 }
}

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

public void testValuesWithEvictedEntries() {
 final int numKeys = 300;
 for (int i = 0; i < numKeys; i++) {
   cache.put(i, i);
 }
 assertFalse("Data Container should not have all keys", numKeys == cache.getAdvancedCache().getDataContainer().size());
 Collection<Object> values = cache.values();
 for (int i = 0; i < numKeys; i++) {
   assertTrue("Value: " + i + " was not found!", values.contains(i));
 }
}

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

public void testKeySet() throws Exception {
 tm().begin();
 cache.put("k1", "v1");
 cache.put("k2", "v2");
 assertEquals(2, cache.keySet().size());
 assertEquals(2, cache.values().size());
 tm().commit();
 assertEquals(2, cache.keySet().size());
 assertEquals(2, cache.values().size());
}

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

private void assertCacheSize(int expectedSize) {
 assertEquals(expectedSize, cache.size());
 assertEquals(expectedSize, cache.keySet().size());
 assertEquals(expectedSize, cache.values().size());
 assertEquals(expectedSize, cache.entrySet().size());
 boolean isEmpty = expectedSize == 0;
 assertEquals(isEmpty, cache.isEmpty());
 assertEquals(isEmpty, cache.keySet().isEmpty());
 assertEquals(isEmpty, cache.values().isEmpty());
 assertEquals(isEmpty, cache.entrySet().isEmpty());
}

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

private void assertCacheSize(int expectedSize) {
 assertEquals(expectedSize, cache.size());
 assertEquals(expectedSize, cache.keySet().size());
 assertEquals(expectedSize, cache.values().size());
 assertEquals(expectedSize, cache.entrySet().size());
 boolean isEmpty = expectedSize == 0;
 assertEquals(isEmpty, cache.isEmpty());
 assertEquals(isEmpty, cache.keySet().isEmpty());
 assertEquals(isEmpty, cache.values().isEmpty());
 assertEquals(isEmpty, cache.entrySet().isEmpty());
}

相关文章