- 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.StatsRecorder
Creates aStatsRecorder
that atomically increments each count and records perURI
stats.static HttpCache.StatsRecorder
Creates aStatsRecorder
that atomically increments each count and doesn't record perURI
stats.static HttpCache.StatsRecorder
disabled()
Returns a disabledStatsRecorder
.void
Called when a request results in a cache hit, either directly or after successful revalidation with the server.void
recordMiss
(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.void
recordNetworkUse
(URI uri) Called when the cache is about to use the network.default void
recordReadFailure
(URI uri) Called when a failure is encountered while reading a response from cache.default void
recordReadSuccess
(URI uri) Called when a response is successfully read from cache.void
recordRequest
(URI uri) Called when a request is intercepted by the cache.void
recordWriteFailure
(URI uri) Called when a failure is encountered while writing a response to cache.void
recordWriteSuccess
(URI uri) Called when a response is successfully written to cache.snapshot()
Returns aStats
snapshot for the recorded statistics for allURIs
.Returns aStats
snapshot 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 aStats
snapshot for the recorded statistics for allURIs
. -
snapshot
Returns aStats
snapshot for the recorded statistics of the givenURI
. -
createConcurrentRecorder
Creates aStatsRecorder
that atomically increments each count and doesn't record perURI
stats.This is the
StatsRecorder
used by default. -
createConcurrentPerUriRecorder
Creates aStatsRecorder
that atomically increments each count and records perURI
stats.Independence of per
URI
stats is dictated byURI.equals(Object)
. That is, stats ofhttps://example.com/a
andhttps://example.com/a?x=y
are recorded independently as theURIs
are not equal, although they have the same host and path. -
disabled
Returns a disabledStatsRecorder
.
-