Class CacheLayer.CacheLayerBuilder

java.lang.Object
org.apache.opendal.layer.CacheLayer.CacheLayerBuilder
Enclosing class:
CacheLayer

public static final class CacheLayer.CacheLayerBuilder extends Object
Configures the cache chunk size and metadata freshness.
  • Method Details

    • chunkSize

      public CacheLayer.CacheLayerBuilder chunkSize(long 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

      public CacheLayer build()
      Builds a layer with its own reference to the cache operator.
      Returns:
      a new cache layer
      Throws:
      IllegalStateException - if the cache operator is closed
      OpenDALException - with code OpenDALException.Code.ConfigInvalid if 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