Interface HttpCache.StatsRecorder
- Enclosing class:
HttpCache
public static interface HttpCache.StatsRecorder
Strategy for recoding
HttpCache statistics. Recording methods are given the URI
of the request being intercepted by the cache.
A StatsRecorder must be thread-safe.
-
Method Summary
Modifier and TypeMethodDescriptionstatic HttpCache.StatsRecorderCreates aStatsRecorderthat atomically increments each count and records perURIstats.static HttpCache.StatsRecorderCreates aStatsRecorderthat atomically increments each count and doesn't record perURIstats.static HttpCache.StatsRecorderdisabled()Returns a disabledStatsRecorder.voidCalled when a request results in a cache hit, either directly or after successful revalidation with the server.voidrecordMiss(URI uri) Called when a request results in a cache miss, either due to a missing cache entry or after failed revalidation with the server.voidrecordNetworkUse(URI uri) Called when the cache is about to use the network.default voidrecordReadFailure(URI uri) Called when a failure is encountered while reading a response from cache.default voidrecordReadSuccess(URI uri) Called when a response is successfully read from cache.voidrecordRequest(URI uri) Called when a request is intercepted by the cache.voidrecordWriteFailure(URI uri) Called when a failure is encountered while writing a response to cache.voidrecordWriteSuccess(URI uri) Called when a response is successfully written to cache.snapshot()Returns aStatssnapshot for the recorded statistics for allURIs.Returns aStatssnapshot for the recorded statistics of the givenURI.
-
Method Details
-
recordRequest
Called when a request is intercepted by the cache. -
recordHit
Called when a request results in a cache hit, either directly or after successful revalidation with the server. -
recordMiss
Called when a request results in a cache miss, either due to a missing cache entry or after failed revalidation with the server. -
recordNetworkUse
Called when the cache is about to use the network. -
recordReadSuccess
Called when a response is successfully read from cache. -
recordReadFailure
Called when a failure is encountered while reading a response from cache. -
recordWriteSuccess
Called when a response is successfully written to cache. -
recordWriteFailure
Called when a failure is encountered while writing a response to cache. -
snapshot
HttpCache.Stats snapshot()Returns aStatssnapshot for the recorded statistics for allURIs. -
snapshot
Returns aStatssnapshot for the recorded statistics of the givenURI. -
createConcurrentRecorder
Creates aStatsRecorderthat atomically increments each count and doesn't record perURIstats.This is the
StatsRecorderused by default. -
createConcurrentPerUriRecorder
Creates aStatsRecorderthat atomically increments each count and records perURIstats.Independence of per
URIstats is dictated byURI.equals(Object). That is, stats ofhttps://example.com/aandhttps://example.com/a?x=yare recorded independently as theURIsare not equal, although they have the same host and path. -
disabled
Returns a disabledStatsRecorder.
-