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
Constructors Constructor Description AlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache<K,V> cache)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description V
apply(K key)
ConcurrentMap<K,V>
asMap()
void
cleanUp()
V
get(K key)
V
get(K k, @NotNull Callable<? extends V> callable)
com.google.common.collect.ImmutableMap<K,V>
getAll(Iterable<? extends K> keys)
com.google.common.collect.ImmutableMap<K,V>
getAllPresent(@NotNull Iterable<?> keys)
V
getIfPresent(Object key)
V
getUnchecked(K key)
void
invalidate(@NotNull Object key)
void
invalidateAll()
void
invalidateAll(@NotNull Iterable<?> objects)
void
put(K k, V v)
void
putAll(Map<? extends K,? extends V> m)
void
refresh(K key)
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)
-
-
-
Method Detail
-
get
public V get(@NotNull K key) throws ExecutionException
- 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
public void refresh(K key)
-
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
public com.google.common.collect.ImmutableMap<K,V> getAllPresent(@NotNull @NotNull Iterable<?> keys)
-
invalidate
public void invalidate(@NotNull @NotNull Object key)
-
invalidateAll
public void invalidateAll()
-
invalidateAll
public void invalidateAll(@NotNull @NotNull Iterable<?> objects)
-
stats
public com.google.common.cache.CacheStats stats()
-
asMap
public ConcurrentMap<K,V> asMap()
-
cleanUp
public void cleanUp()
-
wrap
public static <K,V> com.google.common.cache.LoadingCache<K,V> wrap(com.google.common.cache.LoadingCache<K,V> cache)
-
-