Class HttpCache.Builder

java.lang.Object
com.github.mizosoft.methanol.HttpCache.Builder
Enclosing class:
HttpCache

public static final class HttpCache.Builder extends Object
A builder of HttpCaches.
  • Method Details

    • 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(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(Executor executor)
      Sets the executor to be used by the cache.
    • statsRecorder

      @CanIgnoreReturnValue public HttpCache.Builder statsRecorder(HttpCache.StatsRecorder statsRecorder)
      Sets the cache's StatsRecorder.
    • listener

      @CanIgnoreReturnValue public HttpCache.Builder listener(HttpCache.Listener listener)
      Sets the cache's Listener.
    • 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:
      UncheckedIOException - if a problem occurs while creating the cache