Class AlwaysInvalidatingCacheDecorator<K,V>
java.lang.Object
com.atlassian.bamboo.utils.collections.AlwaysInvalidatingCacheDecorator<K,V>
- All Implemented Interfaces:
com.google.common.base.Function<K,,V> com.google.common.cache.Cache<K,,V> com.google.common.cache.LoadingCache<K,,V> Function<K,V>
- Direct Known Subclasses:
AlwaysInvalidatingCacheDecorator
public class AlwaysInvalidatingCacheDecorator<K,V>
extends Object
implements com.google.common.cache.LoadingCache<K,V>
This decorator ensures that when invalidate() is called while CacheLoader.load() is being executed, the loaded value will be invalidated.
Both get() and invalidate() share the same exclusive reentrant lock, thus making it safe to call invalidate from within load() method.
If invalidate() is called during get(), get() will be retried. This will happen only once, a subsequent attempt to invalidate during get()
will result in a IllegalStateException.
Note: invalidateAll() cannot be called from get().
-
Constructor Summary
ConstructorsConstructorDescriptionAlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache<K, V> cache) -
Method Summary
Modifier and TypeMethodDescriptionasMap()voidcleanUp()getAllPresent(@NotNull Iterable<?> keys) getIfPresent(Object key) getUnchecked(K key) voidinvalidate(@NotNull Object key) voidvoidinvalidateAll(@NotNull Iterable<?> objects) voidvoidvoidlongsize()com.google.common.cache.CacheStatsstats()static <K,V> com.google.common.cache.LoadingCache <K, V> wrap(com.google.common.cache.LoadingCache<K, V> cache) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.common.base.Function
equals
-
Constructor Details
-
AlwaysInvalidatingCacheDecorator
-
-
Method Details
-
get
- Specified by:
getin interfacecom.google.common.cache.LoadingCache<K,V> - Throws:
ExecutionException
-
getAll
public com.google.common.collect.ImmutableMap<K,V> getAll(Iterable<? extends K> keys) throws ExecutionException - Specified by:
getAllin interfacecom.google.common.cache.LoadingCache<K,V> - Throws:
ExecutionException
-
refresh
-
putAll
-
getIfPresent
-
get
public V get(@NotNull K k, @NotNull @NotNull Callable<? extends V> callable) throws ExecutionException - Specified by:
getin interfacecom.google.common.cache.Cache<K,V> - Throws:
ExecutionException
-
getAllPresent
-
getUnchecked
-
apply
-
invalidate
-
invalidateAll
public void invalidateAll() -
invalidateAll
-
size
public long size() -
stats
public com.google.common.cache.CacheStats stats() -
asMap
-
cleanUp
public void cleanUp() -
put
-
wrap
public static <K,V> com.google.common.cache.LoadingCache<K,V> wrap(com.google.common.cache.LoadingCache<K, V> cache)
-