Class CacheKeyGenerator
java.lang.Object
org.apache.hc.client5.http.impl.cache.CacheKeyGenerator
@Contract(threading=STATELESS)
public class CacheKeyGenerator
extends Object
implements org.apache.hc.core5.function.Resolver<URI,String>
- Since:
- 4.1
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenerateKey(URI requestUri) Computes a key for the given requestURIthat 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 givenHttpHostandHttpRequestthat 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 givenHttpHostandHttpRequestthat 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 StringgetFullHeaderValue(org.apache.hc.core5.http.Header[] headers)
-
Field Details
-
INSTANCE
-
-
Constructor Details
-
CacheKeyGenerator
public CacheKeyGenerator()
-
-
Method Details
-
resolve
-
generateKey
Computes a key for the given requestURIthat 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 givenHttpHostandHttpRequestthat can be used as a unique identifier for cached resources.- Parameters:
host- The host for this requestrequest- theHttpRequest- Returns:
- cache key
-
getFullHeaderValue
-
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 givenHttpHostandHttpRequestthat 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 requestrequest- theHttpRequestentry- the parent entry used to track the variants- Returns:
- cache key
-
generateVariantKey
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 requestentry- cache entry in question that has variants- Returns:
- variant key
-