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

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

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

Cache.keySet介绍

暂无

代码示例

代码示例来源:origin: wildfly/wildfly

@Override
public Set<T> getServices() {
  return this.cache.keySet();
}

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

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

代码示例来源: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 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

/**
* Verifies the cache doesn't contain any lock
* @param cache
*/
public static void assertNoLocks(Cache<?,?> cache) {
 LockManager lm = TestingUtil.extractLockManager(cache);
 if (lm != null) {
   for (Object key : cache.keySet()) assert !lm.isLocked(key);
 }
}

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

private List<CacheXid> getKeys(XidImpl xid) {
 return storage.keySet().stream()
    .filter(new XidPredicate(xid))
    .collect(CacheCollectors.serializableCollector(Collectors::toList));
}

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

@Override
  void perform(MagicKey key, Cache<MagicKey, String> cache) {
   Iterator iterator = cache.keySet().iterator();
   assertTrue(iterator.hasNext());
   assertEquals(key, iterator.next());
   assertFalse(iterator.hasNext());
  }
},

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

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

public void testKeySetForEachNonSerializable() {
 assertEquals(0, cache.size());
 cache.put("k1", "v1");
 List<Object> values = new ArrayList<>();
 cache.keySet().forEach(values::add);
 assertEquals(1, values.size());
 assertEquals("k1", values.iterator().next());
}

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

public void testObjKeySetMax() {
 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());
 CacheSet<Integer> keySet = cache.keySet();
 assertEquals(9, createStream(keySet).max(Integer::compare).get().intValue());
}

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

public void testKeySetAfterExpiryInPut(Method m) throws Exception {
 Cache<Integer, String> cache = cm.getCache();
 Map dataIn = new HashMap();
 dataIn.put(1, v(m, 1));
 dataIn.put(2, v(m, 2));
 final long lifespan = EXPIRATION_TIMEOUT;
 cache.putAll(dataIn, lifespan, TimeUnit.MILLISECONDS);
 timeService.advance(lifespan + 100);
 assertEquals(0, cache.keySet().size());
}

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

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

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

public void testForceCommitOnOtherNode() throws Exception {
 String inDoubt = showInDoubtTransactions(0);
 assertInDoubtTxCount(inDoubt, 1);
 assertInDoubtTxCount(showInDoubtTransactions(1), 1);
 List<Long> ids = getInternalIds(inDoubt);
 assertEquals(1, ids.size());
 assertEquals(0, cache(0, "test").keySet().size());
 assertEquals(0, cache(1, "test").keySet().size());
 if (log.isTraceEnabled()) log.trace("Before forcing commit!");
 String result = invokeForceWithId("forceCommit", 0, ids.get(0));
 checkResponse(result, 1);
}

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

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

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

public void testKeySetWithEvictedEntries() {
 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());
 Set<Object> keySet = cache.keySet();
 for (int i = 0; i < numKeys; i++) {
   assertTrue("Key: " + i + " was not found!", keySet.contains(i));
 }
}

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

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

代码示例来源: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 printCacheContents() {
 log.debugf("%d cache managers: %s", getCacheManagers().size(), getCacheManagers());
 for (int i = 0; i < getCacheManagers().size(); i++) {
   Cache<String, String> testCache = manager(i).getCache(TEST_CACHE_NAME);
   DataContainer<String, String> dataContainer = testCache.getAdvancedCache().getDataContainer();
   log.debugf("DC on %s has %d keys: %s", address(i), dataContainer.size(), dataContainer.keySet());
   Set<String> keySet = testCache.keySet();
   log.debugf("Cache %s has %d keys: %s", address(i), keySet.size(), keySet);
 }
}

代码示例来源: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());
}

相关文章