Add sync() methods to HybridCache for consistency guarantees#1090
Add sync() methods to HybridCache for consistency guarantees#1090Barre wants to merge 2 commits intofoyer-rs:mainfrom
Conversation
Add sync(), remove_sync(), insert_sync(), and insert_with_properties_sync() methods to HybridCache to ensure operations complete before returning. This fixes race conditions where: - Deletions could be read after remove() due to async processing - Overwrites could return stale data due to async deletion of old values The new methods provide opt-in consistency guarantees without breaking existing code that doesn't require strict ordering.
|
Hi, @Barre . Thank you for your contribution. I agree to expose the disk cache wait interface, but I have reservations about introducing interfaces like The issue here is that as a cache, foyer allows for the loss of any data. Therefore, the The inconsistency issues you encountered with overwrite or deletion cannot be resolved solely through sync. I am working on fixing these issues. I hope to resolve this through other means rather than prematurely introducing additional interfaces that lead to complexity and confusion. For now, I can expose However, it should be noted that this does not completely solve the problem, as the current design still cannot fully guarantee consistency for overwrite and deletion in order to prevent OOM and throttle the disk. Since most users of foyer use S3 as remote storage, these use cases are generally not involved, and I will gradually fix them in subsequent versions. |
Codecov Report❌ Patch coverage is
... and 53 files with indirect coverage changes 🚀 New features to boost your workflow:
|
3f7f53f to
c009129
Compare
Add sync(), remove_sync(), insert_sync(), and insert_with_properties_sync() methods to HybridCache to ensure operations complete before returning.
This fixes race conditions where:
The new methods provide opt-in consistency guarantees without breaking existing code that doesn't require strict ordering.
What's changed and what's your intention?
Checklist
cargo x(orcargo x --fastinstead if the old tests are not modified) in my local environment.Related issues or PRs (optional)
#1085