Class CacheLayer
- All Implemented Interfaces:
AutoCloseable
Sources must expose a verifiable identity (version, a strong etag, or
last_modified) to be cached; reads from sources without one pass through directly.
Single-path writes and deletes through the layered operator invalidate cached metadata for the
affected paths. External mutations and recursive deletes are bounded by ttl.
Use a cache backend with capacity eviction to reclaim chunks from old object identities. Use separate cache roots or instances for different tenants, endpoints, or credentials because fresh cache hits can skip source I/O.
The layer retains its own reference to the cache operator. The supplied cache handle can be
closed after build() returns. Close the layer after applying it to every operator that
needs it. Those operators can still use the cache after the layer is closed.
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classConfigures the cache chunk size and metadata freshness. -
Method Summary
Modifier and TypeMethodDescriptionstatic CacheLayer.CacheLayerBuilderbuilder(AsyncOperator cache) Creates a builder using an asynchronous cache operator.static CacheLayer.CacheLayerBuilderCreates a builder using a blocking cache operator.voidclose()Releases this layer's reference to the cache.protected longlayer(long nativeOp)
-
Method Details
-
builder
Creates a builder using an asynchronous cache operator.- Parameters:
cache- the cache operator, which must support read, write, and delete- Returns:
- a new builder
- Throws:
NullPointerException- if the cache operator is null
-
builder
Creates a builder using a blocking cache operator.- Parameters:
cache- the cache operator, which must support read, write, and delete- Returns:
- a new builder
- Throws:
NullPointerException- if the cache operator is null
-
layer
-
close
public void close()Releases this layer's reference to the cache. Already-layered operators retain theirs.- Specified by:
closein interfaceAutoCloseable
-