Class BasicHttpCache
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.BasicHttpCache
-
-
Field Summary
Fields Modifier and Type Field Description private HttpCacheInvalidatorcacheInvalidatorprivate CacheKeyGeneratorcacheKeyGeneratorprivate CacheUpdateHandlercacheUpdateHandlerprivate static org.slf4j.LoggerLOGprivate HttpCacheStoragestorage
-
Constructor Summary
Constructors Constructor Description BasicHttpCache()BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage)BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage, CacheKeyGenerator cacheKeyGenerator)BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage, CacheKeyGenerator cacheKeyGenerator, HttpCacheInvalidator cacheInvalidator)BasicHttpCache(CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpCacheEntrycreateCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse originResponse, org.apache.hc.core5.util.ByteArrayBuffer content, java.time.Instant requestSent, java.time.Instant responseReceived)Store aHttpResponsein the cache if possible, and returnvoidflushCacheEntriesFor(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)Clear all matchingHttpCacheEntrys.voidflushCacheEntriesInvalidatedByExchange(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response)FlushHttpCacheEntrys invalidated by the given message exchange.voidflushCacheEntriesInvalidatedByRequest(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)FlushHttpCacheEntrys invalidated by the given requestjava.lang.StringgenerateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)HttpCacheEntrygetCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)Retrieve matchingHttpCacheEntryfrom the cache if it exists.java.util.Map<java.lang.String,Variant>getVariantCacheEntriesWithEtags(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)Retrieve all variants from the cache, if there are no variants then an emptyMapis returnedvoidreuseVariantEntryFor(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, Variant variant)Specifies cache should reuse the given cached variant to satisfy requests whose varying headers match those of the given client request.(package private) voidstoreEntry(java.lang.String cacheKey, HttpCacheEntry entry)(package private) voidstoreInCache(java.lang.String cacheKey, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)(package private) voidstoreVariantEntry(java.lang.String cacheKey, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest req, HttpCacheEntry entry)HttpCacheEntryupdateCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry stale, org.apache.hc.core5.http.HttpResponse originResponse, java.time.Instant requestSent, java.time.Instant responseReceived)Update aHttpCacheEntryusing a 304HttpResponse.HttpCacheEntryupdateVariantCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse originResponse, Variant variant, java.time.Instant requestSent, java.time.Instant responseReceived)Update a specificHttpCacheEntryrepresenting a cached variant using a 304HttpResponse.
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
cacheUpdateHandler
private final CacheUpdateHandler cacheUpdateHandler
-
cacheKeyGenerator
private final CacheKeyGenerator cacheKeyGenerator
-
cacheInvalidator
private final HttpCacheInvalidator cacheInvalidator
-
storage
private final HttpCacheStorage storage
-
-
Constructor Detail
-
BasicHttpCache
public BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage, CacheKeyGenerator cacheKeyGenerator, HttpCacheInvalidator cacheInvalidator)
-
BasicHttpCache
public BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage, CacheKeyGenerator cacheKeyGenerator)
-
BasicHttpCache
public BasicHttpCache(ResourceFactory resourceFactory, HttpCacheStorage storage)
-
BasicHttpCache
public BasicHttpCache(CacheConfig config)
-
BasicHttpCache
public BasicHttpCache()
-
-
Method Detail
-
generateKey
public java.lang.String generateKey(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry cacheEntry)- Specified by:
generateKeyin interfaceHttpCache
-
flushCacheEntriesFor
public void flushCacheEntriesFor(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)Description copied from interface:HttpCacheClear all matchingHttpCacheEntrys.- Specified by:
flushCacheEntriesForin interfaceHttpCache
-
flushCacheEntriesInvalidatedByRequest
public void flushCacheEntriesInvalidatedByRequest(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)Description copied from interface:HttpCacheFlushHttpCacheEntrys invalidated by the given request- Specified by:
flushCacheEntriesInvalidatedByRequestin interfaceHttpCache
-
flushCacheEntriesInvalidatedByExchange
public void flushCacheEntriesInvalidatedByExchange(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse response)Description copied from interface:HttpCacheFlushHttpCacheEntrys invalidated by the given message exchange.- Specified by:
flushCacheEntriesInvalidatedByExchangein interfaceHttpCache
-
storeInCache
void storeInCache(java.lang.String cacheKey, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry entry)
-
storeEntry
void storeEntry(java.lang.String cacheKey, HttpCacheEntry entry)
-
storeVariantEntry
void storeVariantEntry(java.lang.String cacheKey, org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest req, HttpCacheEntry entry)
-
reuseVariantEntryFor
public void reuseVariantEntryFor(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, Variant variant)Description copied from interface:HttpCacheSpecifies cache should reuse the given cached variant to satisfy requests whose varying headers match those of the given client request.- Specified by:
reuseVariantEntryForin interfaceHttpCache
-
updateCacheEntry
public HttpCacheEntry updateCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, HttpCacheEntry stale, org.apache.hc.core5.http.HttpResponse originResponse, java.time.Instant requestSent, java.time.Instant responseReceived)
Description copied from interface:HttpCacheUpdate aHttpCacheEntryusing a 304HttpResponse.- Specified by:
updateCacheEntryin interfaceHttpCache
-
updateVariantCacheEntry
public HttpCacheEntry updateVariantCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse originResponse, Variant variant, java.time.Instant requestSent, java.time.Instant responseReceived)
Description copied from interface:HttpCacheUpdate a specificHttpCacheEntryrepresenting a cached variant using a 304HttpResponse.- Specified by:
updateVariantCacheEntryin interfaceHttpCache
-
createCacheEntry
public HttpCacheEntry createCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.HttpResponse originResponse, org.apache.hc.core5.util.ByteArrayBuffer content, java.time.Instant requestSent, java.time.Instant responseReceived)
Description copied from interface:HttpCacheStore aHttpResponsein the cache if possible, and return- Specified by:
createCacheEntryin interfaceHttpCache
-
getCacheEntry
public HttpCacheEntry getCacheEntry(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)
Description copied from interface:HttpCacheRetrieve matchingHttpCacheEntryfrom the cache if it exists.- Specified by:
getCacheEntryin interfaceHttpCache
-
getVariantCacheEntriesWithEtags
public java.util.Map<java.lang.String,Variant> getVariantCacheEntriesWithEtags(org.apache.hc.core5.http.HttpHost host, org.apache.hc.core5.http.HttpRequest request)
Description copied from interface:HttpCacheRetrieve all variants from the cache, if there are no variants then an emptyMapis returned- Specified by:
getVariantCacheEntriesWithEtagsin interfaceHttpCache
-
-