Class HttpCache.Builder
java.lang.Object
com.github.mizosoft.methanol.HttpCache.Builder
- Enclosing class:
HttpCache
A builder of
HttpCaches.-
Method Summary
Modifier and TypeMethodDescriptionbuild()Creates a newHttpCache.cacheOn(StorageExtension storageExtension) Specifies that HTTP responses are to be persisted on the given storage extension.cacheOnDisk(Path directory, long maxSize) Specifies that HTTP responses are to be persisted on disk, under the given directory, with the given size bound.cacheOnMemory(long maxSize) Specifies that HTTP responses are to be cached on memory with the given size bound.Sets the executor to be used by the cache.listener(HttpCache.Listener listener) Sets the cache'sListener.statsRecorder(HttpCache.StatsRecorder statsRecorder) Sets the cache'sStatsRecorder.synchronizeWrites(boolean synchronizeWrites) Sets whether response completion waits for corresponding cache writes to complete.
-
Method Details
-
cacheOnMemory
Specifies that HTTP responses are to be cached on memory with the given size bound. -
cacheOnDisk
Specifies that HTTP responses are to be persisted on disk, under the given directory, with the given size bound. -
cacheOn
Specifies that HTTP responses are to be persisted on the given storage extension. -
executor
Sets the executor to be used by the cache. -
statsRecorder
Sets the cache'sStatsRecorder. -
listener
Sets the cache'sListener. -
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
Creates a newHttpCache.- Throws:
UncheckedIOException- if a problem occurs while creating the cache
-