Class CacheKeyGenerator

  • All Implemented Interfaces:
    org.apache.hc.core5.function.Resolver<java.net.URI,​java.lang.String>

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.lang.String generateKey​(java.net.URI requestUri)
      Computes a key for the given request URI that can be used as a unique identifier for cached resources.
      java.lang.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.
      java.lang.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.
      java.lang.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.
      private java.lang.String getFullHeaderValue​(org.apache.hc.core5.http.Header[] headers)  
      java.lang.String resolve​(java.net.URI uri)  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CacheKeyGenerator

        public CacheKeyGenerator()
    • Method Detail

      • resolve

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

        public java.lang.String generateKey​(java.net.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 java.lang.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 java.lang.String getFullHeaderValue​(org.apache.hc.core5.http.Header[] headers)
      • generateKey

        public java.lang.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 java.lang.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