Class CacheManager.CacheMap

All Implemented Interfaces:
Serializable, Cloneable, Map<Cache.Key,Object>, SequencedMap<Cache.Key,Object>, Cache
Enclosing class:
CacheManager

private static class CacheManager.CacheMap extends LinkedHashMap<Cache.Key,Object> implements Cache
  • Field Details

    • maxSize

      private final int maxSize
    • ttl

      private long ttl
  • Constructor Details

    • CacheMap

      CacheMap(int maxSize, long ttl)
  • Method Details

    • get

      public <T> HttpResponse<T> get(Cache.Key key, Supplier<HttpResponse<T>> fetcher)
      Description copied from interface: Cache
      Returns the cached HttpResponse for a key or uses the Supplier to fetch the response
      Specified by:
      get in interface Cache
      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

      public <T> CompletableFuture getAsync(Cache.Key key, Supplier<CompletableFuture<HttpResponse<T>>> fetcher)
      Description copied from interface: Cache
      Returns the cached HttpResponse for a key or uses the Supplier to fetch the response
      Specified by:
      getAsync in interface Cache
      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
    • clearOld

      private void clearOld()
    • removeEldestEntry

      protected boolean removeEldestEntry(Map.Entry<Cache.Key,Object> eldest)
      Overrides:
      removeEldestEntry in class LinkedHashMap<Cache.Key,Object>