List of usage examples for com.google.common.cache Cache invalidate
void invalidate(Object key);
From source file:org.geogit.di.caching.ObjectDatabaseDeleteCacheInterceptor.java
@Override public Object invoke(MethodInvocation invocation) throws Throwable { final ObjectId oid = (ObjectId) invocation.getArguments()[0]; final Cache<ObjectId, RevObject> cache = cacheProvider.get().get(); cache.invalidate(oid); return invocation.proceed(); }
From source file:com.ericsson.gerrit.plugins.evictcache.EvictCacheRestApiServlet.java
private void evictCache(Cache<?, ?> cache, String cacheName, Object key) { if (PROJECT_LIST.equals(cacheName)) { // One key is holding the list of projects cache.invalidateAll();/*from ww w . ja v a 2 s . c o m*/ } else { cache.invalidate(key); } logger.debug("Invalidated " + cacheName); }
From source file:rickbw.incubator.cache.MultiCache.java
@Override public final void invalidate(final Object elementKey) { final Cache<K, V> cache = getCache(elementKey); if (cache != null) { cache.invalidate(elementKey); }/*from w w w . j a va 2s . c om*/ }
From source file:org.helios.nash.handler.script.ScriptExecutor.java
/** * Prepares and executes a script/*from w w w . j a v a2 s .c o m*/ * @param request the nash request requesting the script * @param type The script type * @param name The script name * @param source The source of the script. If null, assumed to be a named script request * @param arguments The script arguments */ protected void processScript(NashRequest request, String type, String name, String source, String[] arguments) { try { Cache<String, CompiledScript> typeCache = compiledScripts.get(type); if (source != null) { typeCache.invalidate(name); } CompiledScript script = source == null ? typeCache.getIfPresent(name) : typeCache.get(name, compileScript(type, source)); if (script == null) { throw new Exception("The named script [" + name + "] was not found"); } SimpleBindings bindings = new SimpleBindings(); bindings.put(ScriptEngine.ARGV, "args"); bindings.put("args", arguments); bindings.putAll(RequestHandlerRegistry.getInstance().getBindings()); log.info("Bindings:[" + bindings + "]"); log.info("Executing....."); Object result = script.eval(bindings); if (result != null) { System.out.println(result); } log.info("Executed. Result:" + result); request.end(); } catch (Exception ex) { throwError(request, "Failed to execute script [" + type + "/" + name + "]", ex); } }
From source file:com.toro.torod.cursors.DefaultCursorManager.java
@Override public void close(CursorId cursorId) throws IllegalArgumentException { eventAccess();/*from ww w . j a v a 2 s . c om*/ CursorProperties removed = withoutTimeout.remove(cursorId); if (removed != null) { removalListener.onRemoval(cursorId, removed); } withTimeout.invalidate(cursorId); for (Cache<CursorId, CursorProperties> cache : oldCaches) { cache.invalidate(cursorId); } }
From source file:rickbw.incubator.cache.MultiCache.java
@Override public final void invalidateAll(final Iterable<?> elementKeys) { for (final Object elementKey : elementKeys) { final Cache<K, V> cache = getCache(elementKey); if (cache != null) { cache.invalidate(elementKey); }/* ww w .j av a 2s . c om*/ } }
From source file:org.geogit.di.caching.ObjectDatabaseDeleteAllCacheInterceptor.java
@Override public Object invoke(MethodInvocation invocation) throws Throwable { final Cache<ObjectId, RevObject> cache = cacheProvider.get().get(); @SuppressWarnings("unchecked") Iterator<ObjectId> ids = (Iterator<ObjectId>) invocation.getArguments()[0]; ids = Iterators.transform(ids, new Function<ObjectId, ObjectId>() { @Override/*w w w . j ava2 s. c o m*/ public ObjectId apply(ObjectId input) { cache.invalidate(input); return input; } }); invocation.getArguments()[0] = ids; return invocation.proceed(); }
From source file:com.google.gerrit.server.account.AccountState.java
/** * Store a property for later retrieval. * * <p>This method is thread-safe.// w w w. ja v a2 s. c o m * * @param key unique property key. * @param value value to store; or {@code null} to clear the value. */ public <T> void put(PropertyKey<T> key, @Nullable T value) { Cache<PropertyKey<Object>, Object> p = properties(value != null); if (p != null) { @SuppressWarnings("unchecked") PropertyKey<Object> k = (PropertyKey<Object>) key; if (value != null) { p.put(k, value); } else { p.invalidate(k); } } }
From source file:com.tesora.dve.sql.schema.cache.SchemaCache.java
@Override public void invalidate(SchemaCacheKey<?> sck) { Cache<SchemaCacheKey<?>, Object> c = getSubCache(sck.getCacheSegment()); c.invalidate(sck); }
From source file:com.eucalyptus.auth.euare.CachingPrincipalProvider.java
private UserPrincipal cache(final PrincipalCacheKey key, final PrincipalLoader loader) throws AuthException { PrincipalCacheValue principalValue = null; final Cache<PrincipalCacheKey, PrincipalCacheValue> cache = cache(); try {/*from w w w .j a va 2 s .c o m*/ principalValue = cache.get(key, loader.callable(null)); if (principalValue.updated + AuthenticationProperties.getAuthorizationExpiry() < System .currentTimeMillis()) { cache.invalidate(key); // invalidate expired and refresh principalValue = cache.get(key, loader.callable(principalValue.principal)); } return principalValue.principal; } catch (final ExecutionException e) { // reuse cached value on failure within configured limit, but not for web service error responses if (!AsyncExceptions.asWebServiceError(e).isPresent() && principalValue != null && principalValue.created + AuthenticationProperties.getAuthorizationReuseExpiry() > System .currentTimeMillis()) { cache.put(key, new PrincipalCacheValue(principalValue)); return principalValue.principal; } if (e.getCause() instanceof AuthException) { throw (AuthException) e.getCause(); } else { throw new AuthException(e); } } }