Package org.apache.maven.api.cache
Interface RequestCache
- All Known Implementing Classes:
AbstractRequestCache
,DefaultRequestCache
Interface for caching request results in Maven. This cache implementation provides
methods for executing and optionally caching both single requests and batches of requests.
The cache behavior is determined by the cache retention specified in the request's metadata.
Results can be cached at different policies (forever, session, request, or not at all)
based on the CacheRetention
associated with the request.
- Since:
- 4.0.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionExecutes and optionally caches a request using the provided supplier function.Executes and optionally caches a batch of requests using the provided supplier function.
-
Method Details
-
request
Executes and optionally caches a request using the provided supplier function. If caching is enabled for this session, the result will be cached and subsequent identical requests will return the cached value without re-executing the supplier.The caching behavior is determined by the cache retention specified in the request's metadata. If an error occurs during execution, it will be cached and re-thrown for subsequent identical requests.
- Type Parameters:
REQ
- The request typeREP
- The response type- Parameters:
req
- The request object used as the cache keysupplier
- The function to execute and cache the result- Returns:
- The result from the supplier (either fresh or cached)
- Throws:
RuntimeException
- Any exception thrown by the supplier will be cached and re-thrown on subsequent calls
-
requests
<REQ extends Request<?>,REP extends Result<REQ>> List<REP> requests(List<REQ> req, Function<List<REQ>, List<REP>> supplier) Executes and optionally caches a batch of requests using the provided supplier function. This method allows for efficient batch processing of multiple requests.The implementation may optimize the execution by:
- Returning cached results for previously executed requests
- Grouping similar requests for batch processing
- Processing requests in parallel where appropriate
- Type Parameters:
REQ
- The request typeREP
- The response type- Parameters:
req
- List of requests to processsupplier
- 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
-