public class ThreadScopedCaches extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
ThreadScopedCaches.Key<K,V>
Interface for keys for this cache.
|
Constructor and Description |
---|
ThreadScopedCaches() |
Modifier and Type | Method and Description |
---|---|
static <K,V> V |
getValue(ThreadScopedCaches.Key<K,V> cacheKey,
K key,
Supplier<? extends V> supplier)
Returns the value called by
supplier.get or a previously cached value. |
static void |
inCachingScope(Runnable runnable) |
static <K,V> ThreadScopedCaches.Key<K,V> |
makeKey(Class<?> aClass)
The returned keys rely on identity comparison.
|
public static <K,V> V getValue(ThreadScopedCaches.Key<K,V> cacheKey, K key, Supplier<? extends V> supplier)
supplier.get
or a previously cached value.
The cache is scoped to the current request and will be cleared at the end of the request.
No caching will apply if invoked outside a request.
No caching will apply within a mutative request.cacheKey
- a key to identify the cachekey
- a sub-key to cache the specific value undersupplier
- will be called to return the object theRuntimeException
- if thrown by supplier.get()public static void inCachingScope(Runnable runnable)
public static <K,V> ThreadScopedCaches.Key<K,V> makeKey(Class<?> aClass)
Copyright © 2018 Atlassian Software Systems Pty Ltd. All rights reserved.