Module methanol

Class HttpCache.Builder

  • Enclosing class:
    HttpCache

    public static final class HttpCache.Builder
    extends java.lang.Object
    A builder of HttpCaches.
    • Method Detail

      • cacheOnMemory

        @CanIgnoreReturnValue
        public HttpCache.Builder cacheOnMemory​(long maxSize)
        Specifies that HTTP responses are to be cached on memory with the given size bound.
      • cacheOnDisk

        @CanIgnoreReturnValue
        public HttpCache.Builder cacheOnDisk​(java.nio.file.Path directory,
                                             long maxSize)
        Specifies that HTTP responses are to be persisted on disk, under the given directory, with the given size bound.
      • cacheOn

        @CanIgnoreReturnValue
        public HttpCache.Builder cacheOn​(StorageExtension storageExtension)
        Specifies that HTTP responses are to be persisted on the given storage extension.
      • executor

        @CanIgnoreReturnValue
        public HttpCache.Builder executor​(java.util.concurrent.Executor executor)
        Sets the executor to be used by the cache.
      • synchronizeWrites

        @CanIgnoreReturnValue
        public HttpCache.Builder synchronizeWrites​(boolean synchronizeWrites)
        Sets whether response completion waits for corresponding cache writes to complete. If this setting is false, which is the default, cache writes may continue in background even after the corresponding response is completed. Setting this to true makes sure that cache writing is done after the corresponding response is completed.

        To increase concurrency, this setting should generally be left unset. It is intended to be set to true if predictability is desired, typically in situations like testing.

      • build

        public HttpCache build()
        Creates a new HttpCache.
        Throws:
        java.io.UncheckedIOException - if a problem occurs while creating the cache