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 CacheKeyGenerator
cacheKeyGenerator
private org.apache.commons.logging.Log
log
private HttpCacheStorage
storage
-
Constructor Summary
Constructors Constructor Description CacheInvalidator(CacheKeyGenerator uriExtractor, HttpCacheStorage storage)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
flushAbsoluteUriFromSameHost(java.net.URL reqURL, java.lang.String uri)
private void
flushEntry(java.lang.String uri)
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.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.private void
flushLocationCacheEntry(java.net.URL reqURL, org.apache.http.HttpResponse response, java.net.URL location)
protected void
flushRelativeUriFromSameHost(java.net.URL reqURL, java.lang.String relUri)
protected void
flushUriIfSameHost(java.net.URL requestURL, java.net.URL targetURL)
private java.net.URL
getAbsoluteURL(java.lang.String uri)
private java.net.URL
getContentLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
private HttpCacheEntry
getEntry(java.lang.String theUri)
private java.net.URL
getLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
private java.net.URL
getRelativeURL(java.net.URL reqURL, java.lang.String relUri)
private boolean
isAHeadCacheEntry(HttpCacheEntry parentCacheEntry)
private boolean
notGetOrHeadRequest(java.lang.String method)
private boolean
requestIsGet(org.apache.http.HttpRequest req)
protected boolean
requestShouldNotBeCached(org.apache.http.HttpRequest req)
private boolean
responseAndEntryEtagsDiffer(org.apache.http.HttpResponse response, HttpCacheEntry entry)
private boolean
responseDateOlderThanEntryDate(org.apache.http.HttpResponse response, HttpCacheEntry entry)
private boolean
shouldInvalidateHeadCacheEntry(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:
flushInvalidatedCacheEntries
in 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:
flushInvalidatedCacheEntries
in 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)
-
-