fix(layer/foyers): support suffix read#7738
Open
dentiny wants to merge 2 commits into
Open
Conversation
Xuanwo
reviewed
Jun 12, 2026
Member
Author
There was a problem hiding this comment.
Hi may I ask for some context on foyer/cache layer? I, somehow, didn't find the a related open issue.
The most relevant issue might be #7107, which reads to me:
- we're working on a more general caching layer
- foyer layer should be replaced with foyer service after caching layer implemented
Currently without foyer layer, the gap seems to be we don't have a transparent caching impl?
eg, caching layer impl
let cache = HybridCacheBuilder::new()
.memory(64 * 1024 * 1024) // 64MB memory
.storage()
.build()
.await?;
let op = Operator::new(S3::default())?
.layer(FoyerLayer::new(cache).with_size_limit(0..10 * 1024 * 1024))
.finish();
// transparent
let data = op.read("path/to/file").await?;while for caching service we need to explicitly do lookaside cache
let cache_op = Operator::new(Foyer::new().memory(64 * 1024 * 1024))?.finish();
let source_op = Operator::new(S3::default())?.finish();
// lookaside cache
let data = match cache_op.read("path/to/file").await {
Ok(data) => data,
Err(e) if e.kind() == ErrorKind::NotFound => {
let data = source_op.read("path/to/file").await?;
let _ = cache_op.write("path/to/file", data.clone()).await; // best-effort fill
data
}
Err(e) => return Err(e),
};after caching layer implemented
let cache_op = Operator::new(
Foyer::new()
.memory(64 * 1024 * 1024)
.disk_path("/tmp/cache")
.disk_capacity(16 * 1024 * 1024 * 1024)
)?.finish();
let op = Operator::new(S3::default())?
.layer(CacheLayer::new(cache_op, WholeCachePolicy::new()))
.finish();
// transparent
let data = op.read("path/to/file").await?;In one word, foyer layer, at least for now, still benefits?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #7736
Rationale for this change
The support for suffix read feature should be decided by storage backends, and layers should panic on this feature.
What changes are included in this PR?
Change the way how full object is sliced with suffix read involved.
Are there any user-facing changes?
No.
AI Usage Statement
fable-5 helped me make the code change for me, opus-4.6 and me doing code review.