@Override public void evict(Object key) { this.cache.invalidate(key); }
@Override public void invalidate(Object key) { cache.invalidate(key); }
/** * {@inheritDoc} */ @Override public void invalidate(K key) { cache.invalidate(key); }
@Override public void evict(Object key) { this.cache.invalidate(key); }
@Override public void delete(final String id) { cache.invalidate(id); }
@Override public Task<Void> remove(final RemoteReference<?> remoteReference) { if (logger.isDebugEnabled()) { logger.debug("Remove {} from this node.", remoteReference); } localAddressCache.invalidate(remoteReference); return Task.done(); }
@Override public Task<Void> flush(Actor actor) { final RemoteReference actorReference = (RemoteReference) actor; masterCache.asMap().forEach((method, cache) -> { cache.invalidate(actorReference); }); return Task.done(); }
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); } } } }
@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); }
@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())); } }
if (uncachedAttrs == null) { cache.invalidate(pathAndEncoding); return null; cache.invalidate(pathAndEncoding); return uncachedFile; cache.invalidate(pathAndEncoding); return cache(ctx, pathAndEncoding, uncachedFile);
@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())); }
@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)); }
@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)); } }
@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)); }
localAddressCache.invalidate(toReference); return locateActor(invocation.getToReference(), true) .whenComplete((r, e) -> {
@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)); }
@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())); } }
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)); }
cache.invalidate(sideEffect.get());