-
- Enclosing class:
- HttpCache
public static interface HttpCache.StatsRecorderStrategy for recodingHttpCachestatistics. Recording methods are given theURIof the request being intercepted by the cache.A
StatsRecordermust be thread-safe.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static HttpCache.StatsRecordercreateConcurrentPerUriRecorder()Creates aStatsRecorderthat atomically increments each count and records perURIstats.static HttpCache.StatsRecordercreateConcurrentRecorder()Creates aStatsRecorderthat atomically increments each count and doesn't record perURIstats.static HttpCache.StatsRecorderdisabled()Returns a disabledStatsRecorder.voidrecordHit(java.net.URI uri)Called when a request results in a cache hit, either directly or after successful revalidation with the server.voidrecordMiss(java.net.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(java.net.URI uri)Called when the cache is about to use the network.default voidrecordReadFailure(java.net.URI uri)Called when a failure is encountered while reading a response from cache.default voidrecordReadSuccess(java.net.URI uri)Called when a response is successfully read from cache.voidrecordRequest(java.net.URI uri)Called when a request is intercepted by the cache.voidrecordWriteFailure(java.net.URI uri)Called when a failure is encountered while writing a response to cache.voidrecordWriteSuccess(java.net.URI uri)Called when a response is successfully written to cache.HttpCache.Statssnapshot()Returns aStatssnapshot for the recorded statistics for allURIs.HttpCache.Statssnapshot(java.net.URI uri)Returns aStatssnapshot for the recorded statistics of the givenURI.
-
-
-
Method Detail
-
recordRequest
void recordRequest(java.net.URI uri)
Called when a request is intercepted by the cache.
-
recordHit
void recordHit(java.net.URI uri)
Called when a request results in a cache hit, either directly or after successful revalidation with the server.
-
recordMiss
void recordMiss(java.net.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.
-
recordNetworkUse
void recordNetworkUse(java.net.URI uri)
Called when the cache is about to use the network.
-
recordReadSuccess
default void recordReadSuccess(java.net.URI uri)
Called when a response is successfully read from cache.
-
recordReadFailure
default void recordReadFailure(java.net.URI uri)
Called when a failure is encountered while reading a response from cache.
-
recordWriteSuccess
void recordWriteSuccess(java.net.URI uri)
Called when a response is successfully written to cache.
-
recordWriteFailure
void recordWriteFailure(java.net.URI uri)
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
HttpCache.Stats snapshot(java.net.URI uri)
Returns aStatssnapshot for the recorded statistics of the givenURI.
-
createConcurrentRecorder
static HttpCache.StatsRecorder createConcurrentRecorder()
Creates aStatsRecorderthat atomically increments each count and doesn't record perURIstats.This is the
StatsRecorderused by default.
-
createConcurrentPerUriRecorder
static HttpCache.StatsRecorder 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
static HttpCache.StatsRecorder disabled()
Returns a disabledStatsRecorder.
-
-