Class CacheKeyGenerator
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.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
-
-
Field Summary
Fields Modifier and Type Field Description static CacheKeyGenerator
INSTANCE
-
Constructor Summary
Constructors Constructor Description CacheKeyGenerator()
-
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 requestURI
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 givenHttpHost
andHttpRequest
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 givenHttpHost
andHttpRequest
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)
-
-
-
Field Detail
-
INSTANCE
public static final CacheKeyGenerator INSTANCE
-
-
Method Detail
-
resolve
public java.lang.String resolve(java.net.URI uri)
- Specified by:
resolve
in interfaceorg.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 requestURI
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 givenHttpHost
andHttpRequest
that can be used as a unique identifier for cached resources.- Parameters:
host
- The host for this requestrequest
- theHttpRequest
- 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 givenHttpHost
andHttpRequest
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 requestrequest
- theHttpRequest
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 requestentry
- cache entry in question that has variants- Returns:
- variant key
-
-