本文整理了Java中com.github.benmanes.caffeine.cache.Cache.invalidateAll()
方法的一些代码示例,展示了Cache.invalidateAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.invalidateAll()
方法的具体详情如下:
包路径:com.github.benmanes.caffeine.cache.Cache
类名称:Cache
方法名:invalidateAll
[英]Discards all entries in the cache. The behavior of this operation is undefined for an entry that is being loaded and is otherwise not present.
[中]丢弃缓存中的所有项。对于正在加载且不存在的条目,此操作的行为未定义。
代码示例来源:origin: spring-projects/spring-framework
@Override
public void clear() {
this.cache.invalidateAll();
}
代码示例来源:origin: ben-manes/caffeine
@Override
public void clear() {
requireNotClosed();
cache.invalidateAll();
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, maximumSize = Maximum.FULL,
weigher = CacheWeigher.COLLECTION, population = Population.EMPTY,
keys = ReferenceType.STRONG, values = ReferenceType.STRONG)
public void invalidateAll(Cache<String, List<Integer>> cache,
CacheContext context, Eviction<?, ?> eviction) {
cache.putAll(ImmutableMap.of("a", asList(1, 2, 3), "b", asList(1)));
cache.invalidateAll();
assertThat(cache.estimatedSize(), is(0L));
assertThat(eviction.weightedSize().getAsLong(), is(0L));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, initialCapacity = InitialCapacity.EXCESSIVE,
maximumSize = Maximum.FULL)
public void coldest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
Eviction<Integer, Integer> eviction) {
Map<Integer, Integer> coldest = eviction.coldest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(coldest, is(equalTo(context.original())));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, initialCapacity = InitialCapacity.EXCESSIVE,
maximumSize = Maximum.FULL)
public void hottest_snapshot(Cache<Integer, Integer> cache,
CacheContext context, Eviction<Integer, Integer> eviction) {
Map<Integer, Integer> hottest = eviction.hottest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(hottest, is(equalTo(context.original())));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expiry = CacheExpiry.ACCESS)
public void youngest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
VarExpiration<Integer, Integer> expireAfterVar) {
Map<Integer, Integer> youngest = expireAfterVar.youngest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(youngest, is(equalTo(context.original())));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expiry = CacheExpiry.ACCESS)
public void oldest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
VarExpiration<Integer, Integer> expireAfterVar) {
Map<Integer, Integer> oldest = expireAfterVar.oldest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(oldest, is(equalTo(context.original())));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(population = { Population.PARTIAL, Population.FULL })
public void invalidateAll_partial(Cache<Integer, Integer> cache, CacheContext context) {
List<Integer> keys = cache.asMap().keySet().stream()
.filter(i -> ((i % 2) == 0))
.collect(Collectors.toList());
cache.invalidateAll(keys);
assertThat(cache.estimatedSize(), is(context.initialSize() - keys.size()));
assertThat(cache, hasRemovalNotifications(context, keys.size(), RemovalCause.EXPLICIT));
verifyWriter(context, (verifier, writer) -> {
verifier.deletedAll(Maps.filterKeys(context.original(), Predicates.in(keys)), RemovalCause.EXPLICIT);
});
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, refreshAfterWrite = Expire.ONE_MINUTE)
public void youngest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@RefreshAfterWrite Expiration<Integer, Integer> refreshAfterWrite) {
Map<Integer, Integer> youngest = refreshAfterWrite.youngest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(youngest, is(equalTo(context.original())));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expireAfterAccess = Expire.ONE_MINUTE)
public void oldest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@ExpireAfterAccess Expiration<Integer, Integer> expireAfterAccess) {
Map<Integer, Integer> oldest = expireAfterAccess.oldest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(oldest, is(equalTo(context.original())));
}
代码示例来源:origin: ben-manes/caffeine
@CheckNoWriter @CheckNoStats
@Test(dataProvider = "caches")
@CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING })
public void invalidateAll_empty(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidateAll(new HashSet<>());
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, refreshAfterWrite = Expire.ONE_MINUTE)
public void oldest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@RefreshAfterWrite Expiration<Integer, Integer> refreshAfterWrite) {
Map<Integer, Integer> oldest = refreshAfterWrite.oldest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(oldest, is(equalTo(context.original())));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expireAfterWrite = Expire.ONE_MINUTE)
public void youngest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@ExpireAfterWrite Expiration<Integer, Integer> expireAfterWrite) {
Map<Integer, Integer> youngest = expireAfterWrite.youngest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(youngest, is(equalTo(context.original())));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expireAfterAccess = Expire.ONE_MINUTE)
public void youngest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@ExpireAfterAccess Expiration<Integer, Integer> expireAfterAccess) {
Map<Integer, Integer> youngest = expireAfterAccess.youngest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(youngest, is(equalTo(context.original())));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(implementation = Implementation.Caffeine, expireAfterWrite = Expire.ONE_MINUTE)
public void oldest_snapshot(Cache<Integer, Integer> cache, CacheContext context,
@ExpireAfterWrite Expiration<Integer, Integer> expireAfterWrite) {
Map<Integer, Integer> oldest = expireAfterWrite.oldest(Integer.MAX_VALUE);
cache.invalidateAll();
assertThat(oldest, is(equalTo(context.original())));
}
代码示例来源:origin: ben-manes/caffeine
@CheckNoStats
@Test(dataProvider = "caches", expectedExceptions = DeleteException.class)
@CacheSpec(implementation = Implementation.Caffeine, keys = ReferenceType.STRONG,
population = { Population.SINGLETON, Population.PARTIAL, Population.FULL },
compute = Compute.SYNC, writer = Writer.EXCEPTIONAL, removalListener = Listener.REJECTING)
public void invalidateAll_full_writerFails(Cache<Integer, Integer> cache, CacheContext context) {
try {
cache.invalidateAll();
} finally {
assertThat(cache.asMap(), equalTo(context.original()));
}
}
代码示例来源:origin: ben-manes/caffeine
@CacheSpec
@CheckNoWriter @CheckNoStats
@Test(dataProvider = "caches", expectedExceptions = NullPointerException.class)
public void invalidateAll_null(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidateAll(null);
}
代码示例来源:origin: ben-manes/caffeine
@CheckNoStats
@Test(dataProvider = "caches", expectedExceptions = DeleteException.class)
@CacheSpec(implementation = Implementation.Caffeine, keys = ReferenceType.STRONG,
population = { Population.SINGLETON, Population.PARTIAL, Population.FULL },
compute = Compute.SYNC, writer = Writer.EXCEPTIONAL, removalListener = Listener.REJECTING)
public void invalidateAll_partial_writerFails(Cache<Integer, Integer> cache, CacheContext context) {
try {
cache.invalidateAll(context.firstMiddleLastKeys());
} finally {
assertThat(cache.asMap(), equalTo(context.original()));
}
}
代码示例来源:origin: ben-manes/caffeine
@CacheSpec
@Test(dataProvider = "caches")
public void invalidateAll(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidateAll();
assertThat(cache.estimatedSize(), is(0L));
assertThat(cache, hasRemovalNotifications(context,
context.original().size(), RemovalCause.EXPLICIT));
verifyWriter(context, (verifier, writer) -> {
verifier.deletedAll(context.original(), RemovalCause.EXPLICIT);
});
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(population = { Population.SINGLETON, Population.PARTIAL, Population.FULL })
public void invalidateAll_full(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidateAll(context.original().keySet());
assertThat(cache.estimatedSize(), is(0L));
assertThat(cache, hasRemovalNotifications(context,
context.original().size(), RemovalCause.EXPLICIT));
verifyWriter(context, (verifier, writer) -> {
verifier.deletedAll(context.original(), RemovalCause.EXPLICIT);
});
}
内容来源于网络,如有侵权,请联系作者删除!