本文整理了Java中com.github.benmanes.caffeine.cache.Cache.invalidate()
方法的一些代码示例,展示了Cache.invalidate()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cache.invalidate()
方法的具体详情如下:
包路径:com.github.benmanes.caffeine.cache.Cache
类名称:Cache
方法名:invalidate
[英]Discards any cached value for the key. 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 evict(Object key) {
this.cache.invalidate(key);
}
代码示例来源:origin: ben-manes/caffeine
@Override
public void invalidate(Object key) {
cache.invalidate(key);
}
代码示例来源:origin: rapidoid/rapidoid
/**
* {@inheritDoc}
*/
@Override
public void invalidate(K key) {
cache.invalidate(key);
}
代码示例来源:origin: org.springframework/spring-context-support
@Override
public void evict(Object key) {
this.cache.invalidate(key);
}
代码示例来源:origin: jooby-project/jooby
@Override
public void delete(final String id) {
cache.invalidate(id);
}
代码示例来源:origin: orbit/orbit
@Override
public Task<Void> remove(final RemoteReference<?> remoteReference)
{
if (logger.isDebugEnabled())
{
logger.debug("Remove {} from this node.", remoteReference);
}
localAddressCache.invalidate(remoteReference);
return Task.done();
}
代码示例来源:origin: orbit/orbit
@Override
public Task<Void> flush(Actor actor)
{
final RemoteReference actorReference = (RemoteReference) actor;
masterCache.asMap().forEach((method, cache) -> {
cache.invalidate(actorReference);
});
return Task.done();
}
代码示例来源:origin: orbit/orbit
public void actorDeactivated(RemoteReference remoteReference)
{
// removing the reference from the cluster directory and local caches
getDistributedDirectory().remove(createRemoteKey(remoteReference), clusterPeer.localAddress());
localAddressCache.invalidate(remoteReference);
if(stage.getBroadcastActorDeactivations())
{
for (final NodeInfo info : activeNodes.values())
{
if (!info.address.equals(clusterPeer.localAddress()) && info.state == NodeState.RUNNING)
{
info.nodeCapabilities.remove(remoteReference);
}
}
}
}
代码示例来源:origin: ben-manes/caffeine
@CheckNoWriter @CheckNoStats
@CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING })
@Test(dataProvider = "caches", expectedExceptions = NullPointerException.class)
public void invalidate_nullKey(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidate(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 invalidate_writerFails(Cache<Integer, Integer> cache, CacheContext context) {
try {
cache.invalidate(context.middleKey());
} finally {
assertThat(cache.asMap(), equalTo(context.original()));
}
}
代码示例来源:origin: line/armeria
if (uncachedAttrs == null) {
cache.invalidate(pathAndEncoding);
return null;
cache.invalidate(pathAndEncoding);
return uncachedFile;
cache.invalidate(pathAndEncoding);
return cache(ctx, pathAndEncoding, uncachedFile);
代码示例来源:origin: ben-manes/caffeine
@CheckNoWriter @CheckNoStats
@Test(dataProvider = "caches")
@CacheSpec(removalListener = { Listener.DEFAULT, Listener.REJECTING })
public void invalidate_absent(Cache<Integer, Integer> cache, CacheContext context) {
cache.invalidate(context.absentKey());
assertThat(cache.estimatedSize(), is(context.initialSize()));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(population = { Population.SINGLETON, Population.PARTIAL, Population.FULL })
public void invalidate_present(Cache<Integer, Integer> cache, CacheContext context) {
for (Integer key : context.firstMiddleLastKeys()) {
cache.invalidate(key);
verifyWriter(context, (verifier, writer) -> {
verifier.deleted(key, context.original().get(key), RemovalCause.EXPLICIT);
});
}
int count = context.firstMiddleLastKeys().size();
assertThat(cache.estimatedSize(), is(context.initialSize() - count));
assertThat(cache, hasRemovalNotifications(context, count, RemovalCause.EXPLICIT));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches", expectedExceptions = DeleteException.class)
@CacheSpec(keys = ReferenceType.STRONG, values = {ReferenceType.WEAK, ReferenceType.SOFT},
implementation = Implementation.Caffeine, expireAfterAccess = Expire.DISABLED,
expireAfterWrite = Expire.DISABLED, maximumSize = Maximum.DISABLED,
weigher = CacheWeigher.DEFAULT, population = Population.FULL, stats = Stats.ENABLED,
compute = Compute.SYNC, removalListener = Listener.CONSUMING, writer = Writer.EXCEPTIONAL)
public void invalidate_writerFails(Cache<Integer, Integer> cache, CacheContext context) {
Integer key = context.firstKey();
try {
context.clear();
GcFinalization.awaitFullGc();
cache.invalidate(key);
} finally {
context.disableRejectingCacheWriter();
assertThat(cache.asMap().isEmpty(), is(false));
}
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(requiresWeakOrSoft = true, expireAfterAccess = Expire.DISABLED,
expireAfterWrite = Expire.DISABLED, maximumSize = Maximum.DISABLED,
weigher = CacheWeigher.DEFAULT, population = Population.FULL, stats = Stats.ENABLED,
removalListener = Listener.CONSUMING)
public void invalidate(Cache<Integer, Integer> cache, CacheContext context) {
Integer key = context.firstKey();
Integer value = cache.getIfPresent(key);
context.clear();
GcFinalization.awaitFullGc();
awaitFullCleanup(cache);
assertThat(cache.estimatedSize(), is(1L));
cache.invalidate(key);
assertThat(value, is(notNullValue()));
assertThat(cache.estimatedSize(), is(0L));
long count = context.initialSize() - 1;
assertThat(cache, hasRemovalNotifications(context, count, RemovalCause.COLLECTED));
verifyWriter(context, (verifier, writer) -> verifier.deletions(count, RemovalCause.COLLECTED));
}
代码示例来源:origin: orbit/orbit
localAddressCache.invalidate(toReference);
return locateActor(invocation.getToReference(), true)
.whenComplete((r, e) -> {
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches")
@CacheSpec(population = Population.FULL, expiryTime = Expire.ONE_MINUTE,
mustExpireWithAnyOf = { AFTER_ACCESS, AFTER_WRITE, VARIABLE },
expiry = { CacheExpiry.DISABLED, CacheExpiry.CREATE, CacheExpiry.WRITE, CacheExpiry.ACCESS },
expireAfterAccess = {Expire.DISABLED, Expire.ONE_MINUTE},
expireAfterWrite = {Expire.DISABLED, Expire.ONE_MINUTE})
public void invalidate(Cache<Integer, Integer> cache, CacheContext context) {
context.ticker().advance(1, TimeUnit.MINUTES);
cache.invalidate(context.firstKey());
long count = context.initialSize();
assertThat(cache, hasRemovalNotifications(context, count, RemovalCause.EXPIRED));
verifyWriter(context, (verifier, writer) -> verifier.deletions(count, RemovalCause.EXPIRED));
}
代码示例来源:origin: ben-manes/caffeine
@Test(dataProvider = "caches", expectedExceptions = DeleteException.class)
@CacheSpec(implementation = Implementation.Caffeine, keys = ReferenceType.STRONG,
population = Population.FULL, expiryTime = Expire.ONE_MINUTE,
mustExpireWithAnyOf = { AFTER_ACCESS, AFTER_WRITE, VARIABLE },
expiry = { CacheExpiry.DISABLED, CacheExpiry.CREATE, CacheExpiry.WRITE, CacheExpiry.ACCESS },
expireAfterAccess = {Expire.DISABLED, Expire.ONE_MINUTE},
expireAfterWrite = {Expire.DISABLED, Expire.ONE_MINUTE},
compute = Compute.SYNC, writer = Writer.EXCEPTIONAL, removalListener = Listener.REJECTING)
public void invalidate_writerFails(Cache<Integer, Integer> cache, CacheContext context) {
try {
context.ticker().advance(1, TimeUnit.HOURS);
cache.invalidate(context.firstKey());
} finally {
context.disableRejectingCacheWriter();
context.ticker().advance(-1, TimeUnit.HOURS);
assertThat(cache.asMap(), equalTo(context.original()));
}
}
代码示例来源:origin: mulesoft/mule
LoggerContextCache(ArtifactAwareContextSelector artifactAwareContextSelector, ClassLoader reaperContextClassLoader) {
acquireContextDisposeDelay();
this.artifactAwareContextSelector = artifactAwareContextSelector;
activeContexts = newBuilder().build();
disposedContexts = newBuilder().expireAfterWrite(disposeDelayInMillis, MILLISECONDS)
.removalListener((key, value, cause) -> {
stop((LoggerContext) value);
activeContexts.invalidate(key);
Int2ObjectMap<LoggerContext> newBuiltContexts = new Int2ObjectOpenHashMap<>(builtContexts);
newBuiltContexts.remove(((Integer) key).intValue());
builtContexts = newBuiltContexts;
}).build();
executorService = newScheduledThreadPool(1, new LoggerContextReaperThreadFactory(reaperContextClassLoader));
}
代码示例来源:origin: apache/tinkerpop
cache.invalidate(sideEffect.get());
内容来源于网络,如有侵权,请联系作者删除!