Interface Cache

  • All Known Implementing Classes:
    CacheManager.CacheMap

    public interface Cache
    Cache interface for response caching
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Interface Description
      static class  Cache.Builder  
      static interface  Cache.Key
      Interface for the cache key which can be implemented by consumers The key should implement equals and hashCode It must must return the time the key was created.
      static interface  Cache.KeyGenerator
      A functional interface to generate a cache key
    • Method Detail

      • get

        <T> HttpResponse get​(Cache.Key key,
                             java.util.function.Supplier<HttpResponse<T>> fetcher)
        Returns the cached HttpResponse for a key or uses the Supplier to fetch the response
        Type Parameters:
        T - the type of response
        Parameters:
        key - the cache key
        fetcher - a function to execute the request and return the response. This response should be cached by the implementation
        Returns:
        the Http Response
      • getAsync

        <T> java.util.concurrent.CompletableFuture getAsync​(Cache.Key key,
                                                            java.util.function.Supplier<java.util.concurrent.CompletableFuture<HttpResponse<T>>> fetcher)
        Returns the cached HttpResponse for a key or uses the Supplier to fetch the response
        Type Parameters:
        T - the type of response
        Parameters:
        key - the cache key
        fetcher - a function to execute the request and return the response. This response should be cached by the implementation
        Returns:
        the CompletableFuture for the response
      • builder

        static Cache.Builder builder()
        a builder for cache options
        Returns:
        a new Builder.