org.ehcache.Cache.removeAll()方法的使用及代码示例

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

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

Cache.removeAll介绍

[英]Removes any associated value for the given key set.
[中]删除给定密钥集的任何关联值。

代码示例

代码示例来源:origin: ehcache/ehcache3

@Test
public void testSimpleRemoveAll() throws Exception {
 Cache<Number, CharSequence> testCache = cacheManager.createCache("testCache", newCacheConfigurationBuilder(Number.class, CharSequence.class, heap(10)));
 testCache.put(1, "one");
 testCache.put(2, "two");
 testCache.put(3, "three");
 testCache.removeAll(new HashSet<Number>(Arrays.asList(1, 2)));
 assertThat(testCache.get(1), is(nullValue()));
 assertThat(testCache.get(2), is(nullValue()));
 assertThat(testCache.get(3), is(notNullValue()));
}

代码示例来源:origin: ehcache/ehcache3

testCache.removeAll(new HashSet<Number>(Arrays.asList(1, 2, 3, 4)));
 fail("expected CacheWritingException");
} catch (BulkCacheWritingException ex) {

代码示例来源:origin: ehcache/ehcache3

@Test
public void testBulkOps() {
 TestCacheLoaderWriter loaderWriter = new TestCacheLoaderWriter();
 CacheConfiguration<Long, String> cacheConfiguration = getCacheConfiguration(loaderWriter);
 CacheManager cacheManager = CacheManagerBuilder
     .newCacheManagerBuilder()
     .with(cluster(CLUSTER_URI).autoCreate())
     .withCache("cache-1", cacheConfiguration)
     .build(true);
 Cache<Long, String> cache = cacheManager.getCache("cache-1", Long.class, String.class);
 Map<Long, String> mappings = new HashMap<>();
 for (int i = 1; i <= 5; i++) {
  mappings.put((long) i, "" + i);
 }
 cache.putAll(mappings);
 assertThat(loaderWriter.storeMap.keySet(), containsInAnyOrder(mappings.keySet().toArray()));
 cache.clear();
 Map<Long, String> loadedData = cache.getAll(mappings.keySet());
 assertThat(mappings.keySet(), containsInAnyOrder(loadedData.keySet().toArray()));
 cache.removeAll(mappings.keySet());
 assertThat(loaderWriter.storeMap.isEmpty(), is(true));
}

代码示例来源:origin: ehcache/ehcache3

myCache.removeAll(fewKeysSet);
 fail();
} catch (BulkCacheWritingException bcwe) {

代码示例来源:origin: ehcache/ehcache3

assertThat(all.get(3L), is("three"));
cache2.removeAll(keySet);

代码示例来源:origin: ehcache/ehcache3

myCache.removeAll(fewKeysSet);

代码示例来源:origin: ehcache/ehcache3

myCache.removeAll(fewKeysSet);
for (int i = 0; i < 3; i++) {
 if (i == 0 || i == 2) {

代码示例来源:origin: ehcache/ehcache3

@Test
public void removeAllKeys() {
 cache.put(1, "a");
 cache.put(2, "b");
 changesOf(0, 0, 2, 0);
 cache.removeAll(asSet(1, 2, 3));
 changesOf(0, 0, 0, 2);
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void removeAllKeys() {
 cache.put(1, "a");
 cache.put(2, "b");
 changesOf(0, 0, 2, 0);
 cache.removeAll(asSet(1, 2, 3));
 changesOf(0, 0, 0, 2);
}

代码示例来源:origin: ehcache/ehcache3

testCache.removeAll(keys);

代码示例来源:origin: ehcache/ehcache3

private void innerClear() {
 cache.get(1); // one miss
 cache.getAll(asSet(1, 2, 3)); // 3 misses
 cache.put(1, "a"); // one put
 cache.put(1, "b"); // one put and update
 cache.putAll(Collections.singletonMap(2, "b")); // 1 put
 cache.get(1); // one hit
 cache.remove(1); // one remove
 cache.removeAll(asSet(2)); // one remove
 changesOf(1, 4, 3, 2);
 cacheStatistics.clear();
 changesOf(-1, -4, -3, -2);
}

代码示例来源:origin: ehcache/ehcache3

private void innerClear() {
 cache.get(1); // one miss
 cache.getAll(asSet(1, 2, 3)); // 3 misses
 cache.put(1, "a"); // one put
 cache.put(1, "b"); // one put and update
 cache.putAll(Collections.singletonMap(2, "b")); // 1 put
 cache.get(1); // one hit
 cache.remove(1); // one remove
 cache.removeAll(asSet(2)); // one remove
 changesOf(1, 4, 3, 2);
 tierStatistics.clear();
 changesOf(-1, -4, -3, -2);
}

代码示例来源:origin: ehcache/ehcache3

@Test
public void testRemoveAll_without_cache_writer() throws Exception {
 CacheConfigurationBuilder cacheConfigurationBuilder = CacheConfigurationBuilder.newCacheConfigurationBuilder(String.class, String.class,
   heap(100));
 CacheConfiguration<String, String> cacheConfiguration = cacheConfigurationBuilder.build();
 CacheManagerBuilder<CacheManager> managerBuilder = CacheManagerBuilder.newCacheManagerBuilder();
 CacheManager cacheManager = managerBuilder.withCache("myCache", cacheConfiguration).build(true);
 Cache<String, String> myCache = cacheManager.getCache("myCache", String.class, String.class);
 for (int i = 0; i < 3; i++) {
  myCache.put("key" + i, "value" + i);
 }
 Set<String> fewKeysSet = new HashSet<String>() {
  {
   add("key0");
   add("key2");
  }
 };
 // the call to removeAll
 myCache.removeAll(fewKeysSet);
 for (int i = 0; i < 3; i++) {
  if (i == 0 || i == 2) {
   assertThat(myCache.get("key" + i), is(nullValue()));
  } else {
   assertThat(myCache.get("key" + i), is("value" + i));
  }
 }
}

代码示例来源:origin: net.oschina.j2cache/j2cache-core

@Override
public void evict(String...keys) {
  this.cache.removeAll(Arrays.stream(keys).collect(Collectors.toSet()));
}

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

private void flush(Set<Sha3Hash> keys) {
  pendingPool.removeAll(keys);
  pendingKeys.removeAll(keys);
  log.debug("flushSize={} remainPendingSize={}", keys.size(), pendingKeys.size());
}

相关文章