Class CacheKeyGenerator

java.lang.Object
org.apache.hc.client5.http.impl.cache.CacheKeyGenerator
All Implemented Interfaces:
org.apache.hc.core5.function.Resolver<URI,String>

@Contract(threading=STATELESS) public class CacheKeyGenerator extends Object implements org.apache.hc.core5.function.Resolver<URI,String>
Since:
4.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CacheKeyGenerator
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    generateKey(URI requestUri)
    Computes a key for the given request URI that can be used as a unique identifier for cached resources.
    generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)
    Computes a key for the given HttpHost and HttpRequest that can be used as a unique identifier for cached resources.
    generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
    Computes a key for the given HttpHost and HttpRequest that can be used as a unique identifier for cached resources.
    generateVariantKey(org.apache.hc.core5.http.HttpRequest req, HttpCacheEntry entry)
    Computes a "variant key" from the headers of a given request that are covered by the Vary header of a given cache entry.
    private String
    getFullHeaderValue(org.apache.hc.core5.http.Header[] headers)
     
    resolve(URI uri)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • CacheKeyGenerator

      public CacheKeyGenerator()
  • Method Details

    • resolve

      public String resolve(URI uri)
      Specified by:
      resolve in interface org.apache.hc.core5.function.Resolver<URI,String>
    • generateKey

      public String generateKey(URI requestUri)
      Computes a key for the given request URI that can be used as a unique identifier for cached resources. The URI is expected to in an absolute form.
      Parameters:
      requestUri - request URI
      Returns:
      cache key
    • generateKey

      public String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)
      Computes a key for the given HttpHost and HttpRequest that can be used as a unique identifier for cached resources.
      Parameters:
      host - The host for this request
      request - the HttpRequest
      Returns:
      cache key
    • getFullHeaderValue

      private String getFullHeaderValue(org.apache.hc.core5.http.Header[] headers)
    • generateKey

      public String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
      Computes a key for the given HttpHost and HttpRequest that can be used as a unique identifier for cached resources. if the request has a VARY header the identifier will also include variant key.
      Parameters:
      host - The host for this request
      request - the HttpRequest
      entry - the parent entry used to track the variants
      Returns:
      cache key
    • generateVariantKey

      public String generateVariantKey(org.apache.hc.core5.http.HttpRequest req, HttpCacheEntry entry)
      Computes a "variant key" from the headers of a given request that are covered by the Vary header of a given cache entry. Any request whose varying headers match those of this request should have the same variant key.
      Parameters:
      req - originating request
      entry - cache entry in question that has variants
      Returns:
      variant key