Class MapBasedRequestCacheContext
java.lang.Object
com.atlassian.jira.cache.request.context.MapBasedRequestCacheContext
- All Implemented Interfaces:
RequestCacheContext
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclearAll()Clears all local storage for this thread.voidclearLocalMap(RequestCache<?, ?> requestCache) Clears a specific request cache's local storage for this thread.voidclose()Should be called to indicate the attempt to stop the context.getLocalMap(RequestCache<?, ?> requestCache) Returns the request-scoped storage for the given request cache.getLocalMapIfExists(RequestCache<?, ?> requestCache) Returns the request-scoped storage for the given request cache, if it exists.voidMark the success of adding the value to map returned byRequestCacheContext.getLocalMap(RequestCache)orRequestCacheContext.getLocalMapIfExists(RequestCache)voidopen()Should be called to indicate the start of the context.
-
Constructor Details
-
MapBasedRequestCacheContext
public MapBasedRequestCacheContext(Supplier<Map<Object, Object>> mapSupplier, Runnable cleaningCallback) - Parameters:
mapSupplier- supplier for map returned bygetLocalMap(RequestCache)andgetLocalMapIfExists(RequestCache)cleaningCallback- callback executed duringclose()
-
-
Method Details
-
getLocalMap
Description copied from interface:RequestCacheContextReturns the request-scoped storage for the given request cache. If that storage does not already exist, then one is created.- Specified by:
getLocalMapin interfaceRequestCacheContext- Parameters:
requestCache- the cache for which to locate- Returns:
- the local storage corresponding to the given request cache
-
getLocalMapIfExists
Description copied from interface:RequestCacheContextReturns the request-scoped storage for the given request cache, if it exists.- Specified by:
getLocalMapIfExistsin interfaceRequestCacheContext- Parameters:
requestCache- the cache for which to locate- Returns:
- the local storage corresponding to the given request cache, if it already exists;
otherwise
null.
-
clearAll
public void clearAll()Description copied from interface:RequestCacheContextClears all local storage for this thread. Any request caches that belong to other threads are not affected by this.- Specified by:
clearAllin interfaceRequestCacheContext
-
clearLocalMap
Description copied from interface:RequestCacheContextClears a specific request cache's local storage for this thread. Any request caches that belong to other threads are not affected by this.- Specified by:
clearLocalMapin interfaceRequestCacheContext- Parameters:
requestCache- the cache for which to clear the current thread's local storage
-
open
public void open()Description copied from interface:RequestCacheContextShould be called to indicate the start of the context. Can be called multiple times. Calls to this method must be paired with the same number of calls toRequestCacheContext.close()- Specified by:
openin interfaceRequestCacheContext
-
close
public void close()Description copied from interface:RequestCacheContextShould be called to indicate the attempt to stop the context. Calls to this method must be paired with the same number of calls toRequestCacheContext.open()- Specified by:
closein interfaceRequestCacheContext
-
markValueLoading
public void markValueLoading()Description copied from interface:RequestCacheContextMark the success of adding the value to map returned byRequestCacheContext.getLocalMap(RequestCache)orRequestCacheContext.getLocalMapIfExists(RequestCache)- Specified by:
markValueLoadingin interfaceRequestCacheContext
-