Class RequestCacheFactoryImpl
- All Implemented Interfaces:
RequestCacheFactory
-
Constructor Summary
Constructors -
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.
-
Constructor Details
-
RequestCacheFactoryImpl
-
-
Method Details
-
createRequestCache
Description copied from interface:RequestCacheFactory
Creates a new request-scoped cache with no default cache loader.The cache will behave identically to one created by
RequestCacheFactory.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.- Specified by:
createRequestCache
in interfaceRequestCacheFactory
- Type Parameters:
K
- as forRequestCacheFactory.createRequestCache(String, CacheLoader)
V
- as forRequestCacheFactory.createRequestCache(String, CacheLoader)
- Parameters:
name
- as forRequestCacheFactory.createRequestCache(String, CacheLoader)
- Returns:
- as for
RequestCacheFactory.createRequestCache(String, CacheLoader)
-
createRequestCache
public <K,V> RequestCache<K,V> createRequestCache(String name, com.atlassian.cache.CacheLoader<K, V> cacheLoader) Description copied from interface:RequestCacheFactory
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
.- Specified by:
createRequestCache
in interfaceRequestCacheFactory
- 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
-