Class ThreadScopedCaches
java.lang.Object
com.atlassian.bamboo.utils.scopedcaches.ThreadScopedCaches
- Direct Known Subclasses:
ThreadScopedCaches
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
Interface for keys for this cache. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> V getValue
(ThreadScopedCaches.Key<K, V> cacheKey, K key, Supplier<? extends V> supplier) Returns the value called bysupplier.get
or a previously cached value.static void
inCachingScope
(Runnable runnable) static <T> T
inCachingScope
(Supplier<T> supplier) static <K,
V> ThreadScopedCaches.Key<K, V> The returned keys rely on identity comparison.
-
Constructor Details
-
ThreadScopedCaches
public ThreadScopedCaches()
-
-
Method Details
-
getValue
public static <K,V> V getValue(ThreadScopedCaches.Key<K, V> cacheKey, K key, Supplier<? extends V> supplier) Returns the value called bysupplier.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.- Parameters:
cacheKey
- a key to identify the cachekey
- a sub-key to cache the specific value undersupplier
- will be called to return the object the- Returns:
- the result of supplier.get()
- Throws:
RuntimeException
- if thrown by supplier.get()
-
inCachingScope
-
inCachingScope
-
makeKey
The returned keys rely on identity comparison. You can have multiple such keys per class but each Key instance creates a separate cache.
-