Interface RequestCacheFactory
- All Known Implementing Classes:
RequestCacheFactoryImpl
This is intended to be added to JIRA 6.4 for experimental use in performance fixes. Eventually, it will likely be replaced by a similar mechanism in atlassian-cache but we can use this to iron out desired usage patterns.
- Since:
- v6.4.8
-
Method Summary
Modifier and TypeMethodDescription<K,
V> RequestCache<K, V> createRequestCache
(String name) Creates a new request-scoped cache with no default cache loader.<K,
V> RequestCache<K, V> createRequestCache
(String name, com.atlassian.cache.CacheLoader<K, V> cacheLoader) Creates a new request-scoped cache.
-
Method Details
-
createRequestCache
Creates a new request-scoped cache with no default cache loader.The cache will behave identically to one created by
createRequestCache(String, CacheLoader)
, except that calls toget
without a supplier will throw an exception for values that are not already in the cache. This is mainly intended for cases where only thesupplier
form ofget
will be used exclusively and specifying aCacheLoader
that would never be used is unnecessarily awkward.- Type Parameters:
K
- as forcreateRequestCache(String, CacheLoader)
V
- as forcreateRequestCache(String, CacheLoader)
- Parameters:
name
- as forcreateRequestCache(String, CacheLoader)
- Returns:
- as for
createRequestCache(String, CacheLoader)
-
createRequestCache
<K,V> RequestCache<K,V> createRequestCache(String name, com.atlassian.cache.CacheLoader<K, V> cacheLoader) Creates a new request-scoped cache.Any code that accesses the resulting request-scoped cache from within an HTTP request or a task scheduled using the atlassian-scheduler API will automatically inherit a request-scoped cache. See
JiraThreadLocalUtil
for alternative ways to establish a request context.If a request cache is queried when there is no context established, then caching is completely disabled. All requests to the cache are passed on to the
CacheLoader
.- Type Parameters:
K
- the type of keys used to look up values in this request cacheV
- the type of values returned by this request cache's loader (and therefore by the cache itself)- Parameters:
name
- a name to identify the cache. Although no restrictions are currently enforced for this name (even uniqueness), the name SHOULD follow the recommended conventions of theatlassian-cache
API. Specifically, it should be the fully qualified name of the owning class and the field it uses to hold the request cache reference, separated by a'.'
.cacheLoader
- the loader that provides cached values- Returns:
- the newly created request cache
-