/** * Discards any cached value for key. * @param idOrFullName the key */ public void invalidate(final String idOrFullName) { existenceCache.invalidate(idOrFullName); detailsCache.invalidate(idOrFullName); }
@Subscribe public void handleEtagInvalidation(EtagCacheInvalidation event) { if (event.etag().equals("")) { LOG.trace("Invalidating all collector configuration etags"); cache.invalidateAll(); } else { LOG.trace("Invalidating collector configuration etag {}", event.etag()); cache.invalidate(event.etag()); } }
@Override public void invalidate(K key) { cache.invalidate(key); }
@Override public void purge(LookupCacheKey purgeKey) { if (purgeKey.isPrefixOnly()) { // If the key to purge only contains a prefix, invalidate all keys with that prefix cache.invalidateAll( cache.asMap().keySet().stream() .filter(lookupCacheKey -> purgeKey.prefix().equals(lookupCacheKey.prefix())) .collect(Collectors.toSet()) ); } else { cache.invalidate(purgeKey); } }
/** * Delete synchronized future by connection ID. * * @param connectionId database connection ID */ public void delete(final int connectionId) { resultCache.invalidate(connectionId); } }
public void testLoader() throws ExecutionException { final Cache<Integer, Integer> cache = CacheBuilder.newBuilder().build(); Callable<Integer> loader = new Callable<Integer>() { private int i = 0; @Override public Integer call() throws Exception { return ++i; } }; cache.put(0, 10); assertEquals(Integer.valueOf(10), cache.get(0, loader)); assertEquals(Integer.valueOf(1), cache.get(20, loader)); assertEquals(Integer.valueOf(2), cache.get(34, loader)); cache.invalidate(0); assertEquals(Integer.valueOf(3), cache.get(0, loader)); cache.put(0, 10); cache.invalidateAll(); assertEquals(Integer.valueOf(4), cache.get(0, loader)); }
/** * Delete synchronized future by connection ID. * * @param connectionId database connection ID */ public void delete(final int connectionId) { resultCache.invalidate(connectionId); } }
@Override public void invalidate(Object key) { delegate.invalidate(key); }
@Override public void invalidate(long blockId) { mCache.invalidate(blockId); }
@Override public V remove(K key) throws CacheException { final V old = cache.getIfPresent(key); cache.invalidate(key); return old; }
@Override public void invalidate(Object key) { delegate().invalidate(key); }
public void testInvalidate() { forward.invalidate("key"); verify(mock).invalidate("key"); }
@Override public void handleMessage(ReleaseMessage message, String channel) { logger.info("message received - channel: {}, message: {}", channel, message); String content = message.getMessage(); if (!Topics.APOLLO_RELEASE_TOPIC.equals(channel) || Strings.isNullOrEmpty(content)) { return; } if (!watchedKeys2CacheKey.containsKey(content)) { return; } //create a new list to avoid ConcurrentModificationException List<String> cacheKeys = new ArrayList<>(watchedKeys2CacheKey.get(content)); for (String cacheKey : cacheKeys) { logger.debug("invalidate cache key: {}", cacheKey); localCache.invalidate(cacheKey); } }
@Override public void invalidate(Object key) { delegate().invalidate(key); }
@Override public void invalidate(Object key) { cache.invalidate(key); }
/** * Invalidates an input stream from the cache. * * @param inputStream the cached input stream * @throws IOException when the invalidated input stream fails to release */ public void invalidate(CachedSeekableInputStream inputStream) throws IOException { mUnderFileInputStreamCache.invalidate(inputStream.getResourceId()); release(inputStream); }
@Override public UserDetails call() throws Exception { try { Jenkins jenkins = Jenkins.getInstance(); UserDetails userDetails = jenkins.getSecurityRealm().loadUserByUsername(idOrFullName); if (userDetails == null) { existenceCache.put(this.idOrFullName, Boolean.FALSE); throw new NullPointerException("hudson.security.SecurityRealm should never return null. " + jenkins.getSecurityRealm() + " returned null for idOrFullName='" + idOrFullName + "'"); } existenceCache.put(this.idOrFullName, Boolean.TRUE); return userDetails; } catch (UsernameNotFoundException e) { existenceCache.put(this.idOrFullName, Boolean.FALSE); throw e; } catch (DataAccessException e) { existenceCache.invalidate(this.idOrFullName); throw e; } } }
public void testInvalidate() { Cache<Integer, Integer> cache = CacheBuilder.newBuilder().build(); cache.put(654, 2675); cache.put(2456, 56); cache.put(2, 15); cache.invalidate(654); assertFalse(cache.asMap().containsKey(654)); assertTrue(cache.asMap().containsKey(2456)); assertTrue(cache.asMap().containsKey(2)); }
public void removeOutput(Output output) { final MessageOutput messageOutput = runningMessageOutputs.getIfPresent(output.getId()); if (messageOutput != null) { messageOutput.stop(); } runningMessageOutputs.invalidate(output.getId()); faultCounters.invalidate(output.getId()); } }
public void testInvalidate() { Cache<Integer, Integer> cache = CaffeinatedGuava.build(Caffeine.newBuilder()); cache.put(654, 2675); cache.put(2456, 56); cache.put(2, 15); cache.invalidate(654); assertFalse(cache.asMap().containsKey(654)); assertTrue(cache.asMap().containsKey(2456)); assertTrue(cache.asMap().containsKey(2)); }