org.apache.hc.client5.http.impl.cache

## 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 and Description
    --- | ---
    `static CacheKeyGenerator` | `INSTANCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CacheKeyGenerator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `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.
    `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.
    `String` | `generateKey(URI requestUri)` Computes a key for the given request `URI` that can be used as a unique identifier for cached resources.
    `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.
    `String` | `resolve(URI uri)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### INSTANCE

          public static final CacheKeyGenerator INSTANCE

  - ### Constructor Detail

    - #### CacheKeyGenerator

          public CacheKeyGenerator()

  - ### Method Detail

    - #### 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

    - #### 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

Copyright © 1999–2021 The Apache Software Foundation. All rights reserved.