You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by xu...@apache.org on 2026/10/21 09:59:42 UTC

(opendal) branch main updated: docs(layers/foyer): document whole-object caching for range reads (#8373)

This is an automated email from the ASF dual-hosted git repository.

Xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 798ab86b2 docs(layers/foyer): document whole-object caching for range reads (#8373)
798ab86b2 is described below

commit 798ab86b2cde528dde54499f9eed831ee361595d
Author: Zoe <26...@qq.com>
AuthorDate: Wed Oct 21 17:59:33 2026 +0800

    docs(layers/foyer): document whole-object caching for range reads (#8373)
    
    Explain that cache misses fetch and buffer the entire eligible object before
    returning the requested byte range. Describe the latency and memory implications
    and how with_size_limit excludes large objects from cache fills.
    
    Closes #8370
---
 core/layers/foyer/src/lib.rs | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/core/layers/foyer/src/lib.rs b/core/layers/foyer/src/lib.rs
index a4fc3f0af..80b26a77b 100644
--- a/core/layers/foyer/src/lib.rs
+++ b/core/layers/foyer/src/lib.rs
@@ -152,13 +152,28 @@ impl Code for FoyerValue {
 /// # Operation Behavior
 /// - `write`: [`FoyerLayer`] caches data after the service completes the write.
 /// - `read`: [`FoyerLayer`] checks the cache first. On a cache miss, it reads
-///   from the service and caches the result.
+///   and caches the entire object if its size is within the configured
+///   [`FoyerLayer::with_size_limit`] range, even when only a byte range is requested.
 /// - `delete`: [`FoyerLayer`] removes cached data after a successful delete when the deleter
 ///   closes. A failed delete is not invalidated. Cache invalidation happens before the underlying
 ///   deleter is closed, so the data remains invalidated if closing the deleter fails.
 /// - Other operations: [`FoyerLayer`] passes operations such as `list`, `copy`,
 ///   and `rename` to the service without caching their results.
 ///
+/// # Range Reads
+///
+/// [`FoyerLayer`] caches entire objects, not individual byte ranges. For example,
+/// `operator.read_with("some/path").range(0..1024)` returns only the first 1024
+/// bytes, but on a cache miss the layer fetches and buffers the entire object
+/// before returning that range if the object is eligible for caching. On a cache
+/// hit, the layer returns the requested range from the cached object.
+///
+/// Reading a small range from a large object can therefore transfer and buffer
+/// much more data than requested, increasing read latency and memory usage.
+/// Use [`FoyerLayer::with_size_limit`] to exclude large objects from caching.
+/// On a cache miss, objects outside the configured size range are read directly
+/// from the service using the requested byte range.
+///
 /// # Examples
 ///
 /// ```no_run