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 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 a Stats snapshot for the recorded statistics for all URIs.
      • snapshot

        HttpCache.Stats snapshot​(java.net.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.