Package com.atlassian.confluence.cache
Class ThreadLocalCacheAccessor<K,V>
- java.lang.Object
-
- com.atlassian.confluence.cache.ThreadLocalCacheAccessor<K,V>
-
public class ThreadLocalCacheAccessor<K,V> extends Object
A type-safe way of accessing the threadlocal cache- See Also:
ThreadLocalCache
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
flush()
Flush all thread local cache values.@NonNull V
get(@NonNull K key, @NonNull com.google.common.base.Supplier<V> supplier)
Deprecated.since 7.0.1.V
get(K key)
Retrieve a value from the threadlocal cache@NonNull V
getOrCompute(@NonNull K key, @NonNull Supplier<V> supplier)
Retrieve a value from the threadlocal cache or from the given supplier.void
init()
boolean
isInit()
static <K,V>
ThreadLocalCacheAccessor<K,V>newInstance()
Factory method (for type inference)void
put(K key, V value)
Put a value in the threadlocal cache
-
-
-
Method Detail
-
newInstance
public static <K,V> ThreadLocalCacheAccessor<K,V> newInstance()
Factory method (for type inference)- Returns:
- an appropriately parameterised cache accessor
-
put
public void put(K key, V value)
Put a value in the threadlocal cache- Parameters:
key
- the key to cachevalue
- the value to cache
-
get
public V get(K key)
Retrieve a value from the threadlocal cache- Parameters:
key
- the key for the cache value- Returns:
- the appropriate value, or null if nothing was cached for that key, or the cache has not been initialised
-
get
@Deprecated public @NonNull V get(@NonNull K key, @NonNull com.google.common.base.Supplier<V> supplier)
Deprecated.since 7.0.1. UsegetOrCompute(Object, Supplier)
Retrieve a value from the threadlocal cache or from the given supplier.- Parameters:
key
- the key for the cache valuesupplier
- supplier that can produce the value if needed- Returns:
- the appropriate value as stored in the cache of produced by the supplier
- Since:
- 5.9
-
getOrCompute
public @NonNull V getOrCompute(@NonNull K key, @NonNull Supplier<V> supplier)
Retrieve a value from the threadlocal cache or from the given supplier.- Parameters:
key
- the key for the cache valuesupplier
- supplier that can produce the value if needed- Returns:
- the appropriate value as stored in the cache of produced by the supplier
- Since:
- 7.0.1
-
init
public void init()
-
isInit
public boolean isInit()
-
flush
public void flush()
Flush all thread local cache values.- Since:
- 5.9
-
-