Class AbstractRequestCache
- All Implemented Interfaces:
- RequestCache
- Direct Known Subclasses:
- DefaultRequestCache
RequestCache interface, providing common caching mechanisms
 for executing and caching request results in Maven.
 This class implements caching strategies for individual and batch requests, ensuring that results are stored and reused where appropriate to optimize performance.
- Since:
- 4.0.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected abstract <REQ extends Request<?>, REP extends Result<REQ>>
 CachingSupplier<REQ, REP> Abstract method to be implemented by subclasses to handle caching logic.Executes and optionally caches a single request.Executes and optionally caches a batch of requests.protected static <T extends Throwable>
 void
- 
Constructor Details- 
AbstractRequestCachepublic AbstractRequestCache()
 
- 
- 
Method Details- 
requestpublic <REQ extends Request<?>, REP extends Result<REQ>> REP request(REQ req, Function<REQ, REP> supplier) Executes and optionally caches a single request.The caching behavior is determined by the specific implementation of doCache(Request, Function). If caching is enabled, the result is retrieved from the cache or computed using the supplier function.- Specified by:
- requestin interface- RequestCache
- Type Parameters:
- REQ- The request type
- REP- The response type
- Parameters:
- req- The request object used as the cache key
- supplier- The function that provides the response if not cached
- Returns:
- The cached or computed response
 
- 
requestspublic <REQ extends Request<?>, REP extends Result<REQ>> List<REP> requests(List<REQ> reqs, Function<List<REQ>, List<REP>> supplier) Executes and optionally caches a batch of requests.This method processes a list of requests, utilizing caching where applicable and executing only the non-cached requests using the provided supplier function. If any request in the batch fails, a BatchRequestExceptionis thrown, containing details of all failed requests.- Specified by:
- requestsin interface- RequestCache
- Type Parameters:
- REQ- The request type
- REP- The response type
- Parameters:
- reqs- List of requests to process
- supplier- Function to execute the batch of requests
- Returns:
- List of results corresponding to the input requests
- Throws:
- BatchRequestException- if any request in the batch fails
 
- 
doCacheprotected abstract <REQ extends Request<?>, REP extends Result<REQ>> CachingSupplier<REQ,REP> doCache(REQ req, Function<REQ, REP> supplier) Abstract method to be implemented by subclasses to handle caching logic.This method is responsible for determining whether a request result should be cached, retrieving it from cache if available, or executing the supplier function if necessary. - Type Parameters:
- REQ- The request type
- REP- The response type
- Parameters:
- req- The request object
- supplier- The function that provides the response
- Returns:
- A caching supplier that handles caching logic for the request
 
- 
uncheckedThrow
 
-