Module methanol

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 Details

    • recordRequest

      void recordRequest(URI uri)
      Called when a request is intercepted by the cache.
    • recordHit

      void recordHit(URI uri)
      Called when a request results in a cache hit, either directly or after successful revalidation with the server.
    • recordMiss

      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.
    • recordNetworkUse

      void recordNetworkUse(URI uri)
      Called when the cache is about to use the network.
    • recordReadSuccess

      default void recordReadSuccess(URI uri)
      Called when a response is successfully read from cache.
    • recordReadFailure

      default void recordReadFailure(URI uri)
      Called when a failure is encountered while reading a response from cache.
    • recordWriteSuccess

      void recordWriteSuccess(URI uri)
      Called when a response is successfully written to cache.
    • recordWriteFailure

      void recordWriteFailure(URI uri)
      Called when a failure is encountered while writing a response to cache.
    • snapshot

      HttpCache.Stats snapshot()
      Returns a Stats snapshot for the recorded statistics for all URIs.
    • snapshot

      HttpCache.Stats snapshot(URI uri)
      Returns a Stats snapshot for the recorded statistics of the given URI.
    • createConcurrentRecorder

      static HttpCache.StatsRecorder createConcurrentRecorder()
      Creates a StatsRecorder that atomically increments each count and doesn't record per URI stats.

      This is the StatsRecorder used by default.

    • createConcurrentPerUriRecorder

      static HttpCache.StatsRecorder createConcurrentPerUriRecorder()
      Creates a StatsRecorder that atomically increments each count and records per URI stats.

      Independence of per URI stats is dictated by URI.equals(Object). That is, stats of https://example.com/a and https://example.com/a?x=y are recorded independently as the URIs are not equal, although they have the same host and path.

    • disabled

      static HttpCache.StatsRecorder disabled()
      Returns a disabled StatsRecorder.