Class CacheLayer.CacheLayerBuilder
java.lang.Object
org.apache.opendal.layer.CacheLayer.CacheLayerBuilder
- Enclosing class:
CacheLayer
Configures the cache chunk size and metadata freshness.
-
Method Details
-
chunkSize
Sets the aligned chunk size. Zero restores the default of 1 MiB. The cache operator's advertised maximum total write size caps both the default and explicit sizes.- Parameters:
chunkSize- the chunk size in bytes, or zero to restore the default- Returns:
- this builder
- Throws:
IllegalArgumentException- if the chunk size is negative
-
ttl
Sets the metadata freshness window. The default is 60 seconds. Zero revalidates metadata before serving a reader. Reads of explicitly selected immutable versions skip periodic revalidation.- Parameters:
ttl- the non-negative freshness window- Returns:
- this builder
- Throws:
IllegalArgumentException- if the duration is null or negative
-
build
Builds a layer with its own reference to the cache operator.- Returns:
- a new cache layer
- Throws:
IllegalStateException- if the cache operator is closedOpenDALException- with codeOpenDALException.Code.ConfigInvalidif the cache operator lacks read, write, or delete, the cache operator advertises a maximum total write size of zero, or the chunk size exceeds the native size range
-