com.atlassian.bamboo.collections
Class AlwaysInvalidatingCacheDecorator<K,V>

java.lang.Object
  extended by com.atlassian.bamboo.collections.AlwaysInvalidatingCacheDecorator<K,V>
All Implemented Interfaces:
com.google.common.base.Function<K,V>, com.google.common.cache.Cache<K,V>

public class AlwaysInvalidatingCacheDecorator<K,V>
extends Object
implements com.google.common.cache.Cache<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
AlwaysInvalidatingCacheDecorator(com.google.common.cache.Cache<K,V> cache)
          Deprecated. since 5.6 use AlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache) instead
AlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache<K,V> cache)
           
 
Method Summary
 V apply(K key)
           
 ConcurrentMap<K,V> asMap()
           
 void cleanUp()
           
 V get(K key)
           
 V get(K k, Callable<? extends V> callable)
           
 com.google.common.collect.ImmutableMap<K,V> getAllPresent(Iterable<? extends K> ks)
           
 V getIfPresent(K k)
           
 V getUnchecked(K key)
           
 void invalidate(Object key)
           
 void invalidateAll()
           
 void invalidateAll(Iterable<?> objects)
           
 void put(K k, V v)
           
 long size()
           
 com.google.common.cache.CacheStats stats()
           
static
<K,V> com.google.common.cache.Cache<K,V>
wrap(com.google.common.cache.Cache<K,V> cache)
          Deprecated. since 5.6 use wrap(com.google.common.cache.LoadingCache) instead
static
<K,V> com.google.common.cache.Cache<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 Detail

AlwaysInvalidatingCacheDecorator

@Deprecated
public AlwaysInvalidatingCacheDecorator(com.google.common.cache.Cache<K,V> cache)
Deprecated. since 5.6 use AlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache) instead


AlwaysInvalidatingCacheDecorator

public AlwaysInvalidatingCacheDecorator(com.google.common.cache.LoadingCache<K,V> cache)
Method Detail

get

public V get(@NotNull
             K key)
      throws ExecutionException
Specified by:
get in interface com.google.common.cache.Cache<K,V>
Throws:
ExecutionException

getIfPresent

@Nullable
public V getIfPresent(@NotNull
                               K k)
Specified by:
getIfPresent in interface com.google.common.cache.Cache<K,V>

get

public V get(@NotNull
             K k,
             @NotNull
             Callable<? extends V> callable)
      throws ExecutionException
Specified by:
get in interface com.google.common.cache.Cache<K,V>
Throws:
ExecutionException

getAllPresent

public com.google.common.collect.ImmutableMap<K,V> getAllPresent(@NotNull
                                                                 Iterable<? extends K> ks)
Specified by:
getAllPresent in interface com.google.common.cache.Cache<K,V>

getUnchecked

public V getUnchecked(@NotNull
                      K key)
Specified by:
getUnchecked in interface com.google.common.cache.Cache<K,V>

apply

public V apply(@NotNull
               K key)
Specified by:
apply in interface com.google.common.base.Function<K,V>
Specified by:
apply in interface com.google.common.cache.Cache<K,V>

invalidate

public void invalidate(@NotNull
                       Object key)
Specified by:
invalidate in interface com.google.common.cache.Cache<K,V>

invalidateAll

public void invalidateAll()
Specified by:
invalidateAll in interface com.google.common.cache.Cache<K,V>

invalidateAll

public void invalidateAll(@NotNull
                          Iterable<?> objects)
Specified by:
invalidateAll in interface com.google.common.cache.Cache<K,V>

size

public long size()
Specified by:
size in interface com.google.common.cache.Cache<K,V>

stats

public com.google.common.cache.CacheStats stats()
Specified by:
stats in interface com.google.common.cache.Cache<K,V>

asMap

public ConcurrentMap<K,V> asMap()
Specified by:
asMap in interface com.google.common.cache.Cache<K,V>

cleanUp

public void cleanUp()
Specified by:
cleanUp in interface com.google.common.cache.Cache<K,V>

put

public void put(@NotNull
                K k,
                @NotNull
                V v)
Specified by:
put in interface com.google.common.cache.Cache<K,V>

wrap

@Deprecated
public static <K,V> com.google.common.cache.Cache<K,V> wrap(com.google.common.cache.Cache<K,V> cache)
Deprecated. since 5.6 use wrap(com.google.common.cache.LoadingCache) instead


wrap

public static <K,V> com.google.common.cache.Cache<K,V> wrap(com.google.common.cache.LoadingCache<K,V> cache)


Copyright © 2015 Atlassian Software Systems Pty Ltd. All rights reserved.