- java.lang.Object
-
- com.github.mizosoft.methanol.HttpCache.Builder
-
- Enclosing class:
- HttpCache
public static final class HttpCache.Builder extends java.lang.ObjectA builder ofHttpCaches.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description HttpCachebuild()Creates a newHttpCache.HttpCache.BuildercacheOn(StorageExtension storageExtension)Specifies that HTTP responses are to be persisted on the given storage extension.HttpCache.BuildercacheOnDisk(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.HttpCache.BuildercacheOnMemory(long maxSize)Specifies that HTTP responses are to be cached on memory with the given size bound.HttpCache.Builderexecutor(java.util.concurrent.Executor executor)Sets the executor to be used by the cache.HttpCache.Builderlistener(HttpCache.Listener listener)Sets the cache'sListener.HttpCache.BuilderstatsRecorder(HttpCache.StatsRecorder statsRecorder)Sets the cache'sStatsRecorder.HttpCache.BuildersynchronizeWrites(boolean synchronizeWrites)Sets whether response completion waits for corresponding cache writes to complete.
-
-
-
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.
-
statsRecorder
@CanIgnoreReturnValue public HttpCache.Builder statsRecorder(HttpCache.StatsRecorder statsRecorder)
Sets the cache'sStatsRecorder.
-
listener
@CanIgnoreReturnValue public HttpCache.Builder listener(HttpCache.Listener listener)
Sets the cache'sListener.
-
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 newHttpCache.- Throws:
java.io.UncheckedIOException- if a problem occurs while creating the cache
-
-