- Enclosing class:
HttpCache
public static interface HttpCache.Listener
A listener to request/response & read/write events within the cache.
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidonNetworkUse(HttpRequest request, @Nullable TrackedResponse<?> cacheResponse) Called when the cache is about to use the network due to a cache miss.default voidonReadFailure(HttpRequest request, Throwable exception) Called when a failure is encountered while reading the response body from cache.default voidonReadSuccess(HttpRequest request) Called when the response body has been successfully read from cache.default voidonRequest(HttpRequest request) Called when the cache receives a request.default voidonResponse(HttpRequest request, CacheAwareResponse<?> response) Called when the cache is ready to serve the response.default voidonWriteFailure(HttpRequest request, Throwable exception) Called when a failure is encountered while writing the response to cache.default voidonWriteSuccess(HttpRequest request) Called when the response has been successfully written to cache.
-
Method Details
-
onRequest
Called when the cache receives a request. -
onNetworkUse
Called when the cache is about to use the network due to a cache miss. The given response represents the inapplicable cache response if one was available. -
onResponse
Called when the cache is ready to serve the response. The given response'scache statuscan be examined to know how the response was constructed by the cache. This method is called before the response body is read. -
onReadSuccess
Called when the response body has been successfully read from cache. -
onReadFailure
Called when a failure is encountered while reading the response body from cache. -
onWriteSuccess
Called when the response has been successfully written to cache. -
onWriteFailure
Called when a failure is encountered while writing the response to cache.
-