@Contract(threading=IMMUTABLE_CONDITIONAL) class CacheInvalidator extends java.lang.Object implements HttpCacheInvalidator
Modifier and Type | Field and Description |
---|---|
private CacheKeyGenerator |
cacheKeyGenerator |
private org.apache.commons.logging.Log |
log |
private HttpCacheStorage |
storage |
Constructor and Description |
---|
CacheInvalidator(CacheKeyGenerator uriExtractor,
HttpCacheStorage storage)
|
Modifier and Type | Method and 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) |
private final HttpCacheStorage storage
private final CacheKeyGenerator cacheKeyGenerator
private final org.apache.commons.logging.Log log
public CacheInvalidator(CacheKeyGenerator uriExtractor, HttpCacheStorage storage)
uriExtractor
- Provides identifiers for the keys to store cache entriesstorage
- the cache to store items away inpublic void flushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest req)
flushInvalidatedCacheEntries
in interface HttpCacheInvalidator
host
- The backend host we are talking toreq
- The HttpRequest to that hostprivate boolean shouldInvalidateHeadCacheEntry(org.apache.http.HttpRequest req, HttpCacheEntry parentCacheEntry)
private boolean requestIsGet(org.apache.http.HttpRequest req)
private boolean isAHeadCacheEntry(HttpCacheEntry parentCacheEntry)
private void flushEntry(java.lang.String uri)
private HttpCacheEntry getEntry(java.lang.String theUri)
protected void flushUriIfSameHost(java.net.URL requestURL, java.net.URL targetURL)
protected void flushRelativeUriFromSameHost(java.net.URL reqURL, java.lang.String relUri)
protected boolean flushAbsoluteUriFromSameHost(java.net.URL reqURL, java.lang.String uri)
private java.net.URL getAbsoluteURL(java.lang.String uri)
private java.net.URL getRelativeURL(java.net.URL reqURL, java.lang.String relUri)
protected boolean requestShouldNotBeCached(org.apache.http.HttpRequest req)
private boolean notGetOrHeadRequest(java.lang.String method)
public void flushInvalidatedCacheEntries(org.apache.http.HttpHost host, org.apache.http.HttpRequest request, org.apache.http.HttpResponse response)
flushInvalidatedCacheEntries
in interface HttpCacheInvalidator
private void flushLocationCacheEntry(java.net.URL reqURL, org.apache.http.HttpResponse response, java.net.URL location)
private java.net.URL getContentLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
private java.net.URL getLocationURL(java.net.URL reqURL, org.apache.http.HttpResponse response)
private boolean responseAndEntryEtagsDiffer(org.apache.http.HttpResponse response, HttpCacheEntry entry)
private boolean responseDateOlderThanEntryDate(org.apache.http.HttpResponse response, HttpCacheEntry entry)