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
ConstructorDescriptionAlwaysInvalidatingCacheDecorator
(com.google.common.cache.LoadingCache<K, V> cache) -
Method Summary
Modifier and TypeMethodDescriptionasMap()
void
cleanUp()
getAllPresent
(@NotNull Iterable<?> keys) getIfPresent
(Object key) getUnchecked
(K key) void
invalidate
(@NotNull Object key) void
void
invalidateAll
(@NotNull Iterable<?> objects) void
void
void
long
size()
com.google.common.cache.CacheStats
stats()
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, wait
Methods inherited from interface com.google.common.base.Function
equals
-
Constructor Details
-
AlwaysInvalidatingCacheDecorator
-
-
Method Details
-
get
- Specified by:
get
in 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:
getAll
in 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:
get
in 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)
-