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 voidflush()Flush all thread local cache values.@NonNull Vget(@NonNull K key, @NonNull com.google.common.base.Supplier<V> supplier)Deprecated.since 7.0.1.Vget(K key)Retrieve a value from the threadlocal cache@NonNull VgetOrCompute(@NonNull K key, @NonNull Supplier<V> supplier)Retrieve a value from the threadlocal cache or from the given supplier.voidinit()static <K,V>
ThreadLocalCacheAccessor<K,V>newInstance()Factory method (for type inference)voidput(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()
-
flush
public void flush()
Flush all thread local cache values.- Since:
- 5.9
-
-