Class CacheInvalidator
- java.lang.Object
-
- org.apache.http.impl.client.cache.CacheInvalidator
-
- All Implemented Interfaces:
HttpCacheInvalidator
@Contract(threading=IMMUTABLE_CONDITIONAL) class CacheInvalidator extends java.lang.Object implements HttpCacheInvalidator
Given a particular HttpRequest, flush any cache entries that this request would invalidate.- Since:
- 4.1
-
-
Field Summary
Fields Modifier and Type Field Description private CacheKeyGeneratorcacheKeyGeneratorprivate org.apache.commons.logging.Loglogprivate HttpCacheStoragestorage
-
Constructor Summary
Constructors Constructor Description CacheInvalidator(CacheKeyGenerator uriExtractor, HttpCacheStorage storage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleanflushAbsoluteUriFromSameHost(java.net.URL reqURL, java.lang.String uri)private voidflushEntry(java.lang.String uri)voidflushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest req)Remove cache entries from the cache that are no longer fresh or have been invalidated in some way.voidflushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)Flushes entries that were invalidated by the given response received for the given host/request pair.private voidflushLocationCacheEntry(java.net.URL reqURL, org.apache.http.HttpResponse response, java.net.URL location)protected voidflushRelativeUriFromSameHost(java.net.URL reqURL, java.lang.String relUri)protected voidflushUriIfSameHost(java.net.URL requestURL, java.net.URL targetURL)private java.net.URLgetAbsoluteURL(java.lang.String uri)private java.net.URLgetContentLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)private HttpCacheEntrygetEntry(java.lang.String theUri)private java.net.URLgetLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)private java.net.URLgetRelativeURL(java.net.URL reqURL, java.lang.String relUri)private booleanisAHeadCacheEntry(HttpCacheEntry parentCacheEntry)private booleannotGetOrHeadRequest(java.lang.String method)private booleanrequestIsGet(org.apache.http.HttpRequest req)protected booleanrequestShouldNotBeCached(org.apache.http.HttpRequest req)private booleanresponseAndEntryEtagsDiffer(org.apache.http.HttpResponse response, HttpCacheEntry entry)private booleanresponseDateOlderThanEntryDate(org.apache.http.HttpResponse response, HttpCacheEntry entry)private booleanshouldInvalidateHeadCacheEntry(org.apache.http.HttpRequest req, HttpCacheEntry parentCacheEntry)
-
-
-
Field Detail
-
storage
private final HttpCacheStorage storage
-
cacheKeyGenerator
private final CacheKeyGenerator cacheKeyGenerator
-
log
private final org.apache.commons.logging.Log log
-
-
Constructor Detail
-
CacheInvalidator
public CacheInvalidator(CacheKeyGenerator uriExtractor, HttpCacheStorage storage)
- Parameters:
uriExtractor- Provides identifiers for the keys to store cache entriesstorage- the cache to store items away in
-
-
Method Detail
-
flushInvalidatedCacheEntries
public void flushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest req)Remove cache entries from the cache that are no longer fresh or have been invalidated in some way.- Specified by:
flushInvalidatedCacheEntriesin interfaceHttpCacheInvalidator- Parameters:
host- The backend host we are talking toreq- The HttpRequest to that host
-
shouldInvalidateHeadCacheEntry
private boolean shouldInvalidateHeadCacheEntry(org.apache.http.HttpRequest req, HttpCacheEntry parentCacheEntry)
-
requestIsGet
private boolean requestIsGet(org.apache.http.HttpRequest req)
-
isAHeadCacheEntry
private boolean isAHeadCacheEntry(HttpCacheEntry parentCacheEntry)
-
flushEntry
private void flushEntry(java.lang.String uri)
-
getEntry
private HttpCacheEntry getEntry(java.lang.String theUri)
-
flushUriIfSameHost
protected void flushUriIfSameHost(java.net.URL requestURL, java.net.URL targetURL)
-
flushRelativeUriFromSameHost
protected void flushRelativeUriFromSameHost(java.net.URL reqURL, java.lang.String relUri)
-
flushAbsoluteUriFromSameHost
protected boolean flushAbsoluteUriFromSameHost(java.net.URL reqURL, java.lang.String uri)
-
getAbsoluteURL
private java.net.URL getAbsoluteURL(java.lang.String uri)
-
getRelativeURL
private java.net.URL getRelativeURL(java.net.URL reqURL, java.lang.String relUri)
-
requestShouldNotBeCached
protected boolean requestShouldNotBeCached(org.apache.http.HttpRequest req)
-
notGetOrHeadRequest
private boolean notGetOrHeadRequest(java.lang.String method)
-
flushInvalidatedCacheEntries
public void flushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)Flushes entries that were invalidated by the given response received for the given host/request pair.- Specified by:
flushInvalidatedCacheEntriesin interfaceHttpCacheInvalidator
-
flushLocationCacheEntry
private void flushLocationCacheEntry(java.net.URL reqURL, org.apache.http.HttpResponse response, java.net.URL location)
-
getContentLocationURL
private java.net.URL getContentLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
-
getLocationURL
private java.net.URL getLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
-
responseAndEntryEtagsDiffer
private boolean responseAndEntryEtagsDiffer(org.apache.http.HttpResponse response, HttpCacheEntry entry)
-
responseDateOlderThanEntryDate
private boolean responseDateOlderThanEntryDate(org.apache.http.HttpResponse response, HttpCacheEntry entry)
-
-