Module methanol

Interface HttpCache.Listener

  • Enclosing class:
    HttpCache

    public static interface HttpCache.Listener
    A listener to request/response & read/write events within the cache.
    • Method Summary

      All Methods Instance Methods Default Methods 
      Modifier and Type Method Description
      default void onNetworkUse​(java.net.http.HttpRequest request, @Nullable TrackedResponse<?> cacheResponse)
      Called when the cache is about to use the network due to a cache miss.
      default void onReadFailure​(java.net.http.HttpRequest request, java.lang.Throwable exception)
      Called when a failure is encountered while reading the response body from cache.
      default void onReadSuccess​(java.net.http.HttpRequest request)
      Called when the response body has been successfully read from cache.
      default void onRequest​(java.net.http.HttpRequest request)
      Called when the cache receives a request.
      default void onResponse​(java.net.http.HttpRequest request, CacheAwareResponse<?> response)
      Called when the cache is ready to serve the response.
      default void onWriteFailure​(java.net.http.HttpRequest request, java.lang.Throwable exception)
      Called when a failure is encountered while writing the response to cache.
      default void onWriteSuccess​(java.net.http.HttpRequest request)
      Called when the response has been successfully written to cache.
    • Method Detail

      • onRequest

        default void onRequest​(java.net.http.HttpRequest request)
        Called when the cache receives a request.
      • onNetworkUse

        default void onNetworkUse​(java.net.http.HttpRequest request,
                                  @Nullable TrackedResponse<?> cacheResponse)
        Called when the cache is about to use the network due to a cache miss. The given response represents the inapplicable cache response if one was available.
      • onResponse

        default void onResponse​(java.net.http.HttpRequest request,
                                CacheAwareResponse<?> response)
        Called when the cache is ready to serve the response. The given response's cache status can be examined to know how the response was constructed by the cache. This method is called before the response body is read.
      • onReadSuccess

        default void onReadSuccess​(java.net.http.HttpRequest request)
        Called when the response body has been successfully read from cache.
      • onReadFailure

        default void onReadFailure​(java.net.http.HttpRequest request,
                                   java.lang.Throwable exception)
        Called when a failure is encountered while reading the response body from cache.
      • onWriteSuccess

        default void onWriteSuccess​(java.net.http.HttpRequest request)
        Called when the response has been successfully written to cache.
      • onWriteFailure

        default void onWriteFailure​(java.net.http.HttpRequest request,
                                    java.lang.Throwable exception)
        Called when a failure is encountered while writing the response to cache.