Interface RequestCache

All Known Implementing Classes:
AbstractRequestCache, DefaultRequestCache

@Experimental public interface RequestCache
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 Type
    Method
    Description
    <REQ extends Request<?>, REP extends Result<REQ>>
    REP
    request(REQ req, Function<REQ,REP> supplier)
    Executes and optionally caches a request using the provided supplier function.
    <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.
  • Method Details

    • request

      <REQ extends Request<?>, REP extends Result<REQ>> REP request(REQ req, Function<REQ,REP> supplier)
      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 type
      REP - The response type
      Parameters:
      req - The request object used as the cache key
      supplier - 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 type
      REP - The response type
      Parameters:
      req - 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