Package com.atlassian.confluence.cache
Class ThreadLocalCacheAccessor<K,V>
java.lang.Object
com.atlassian.confluence.cache.ThreadLocalCacheAccessor<K,V>
A type-safe way of accessing the threadlocal cache
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
flush()
Flush all thread local cache values.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> Factory method (for type inference)void
Put a value in the threadlocal cache
-
Method Details
-
newInstance
Factory method (for type inference)- Returns:
- an appropriately parameterised cache accessor
-
put
Put a value in the threadlocal cache- Parameters:
key
- the key to cachevalue
- the value to cache
-
get
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
-
getOrCompute
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
-