refactor: unify cache traits and enhance policy support#85
Merged
Conversation
This commit introduces a breaking change by replacing multiple cache traits (`ReadOnlyCache`, `CoreCache`, `MutableCache`, `FifoCacheTrait`, `LruCacheTrait`, `LfuCacheTrait`, `LrukCacheTrait`) with a single `Cache<K, V>` trait. Five optional capability traits have been added: `EvictingCache`, `VictimInspectable`, `RecencyTracking`, `FrequencyTracking`, and `HistoryTracking`. Policy-specific methods are now inherent methods, and the `builder::Cache` has been renamed to `builder::DynCache` to avoid naming collisions. All cache policies have been updated to implement the new `Cache<K, V>` trait, ensuring universal support for `peek` and `remove` operations.
Updated the documentation for `SlruCore` to streamline the description of key removal via [`Cache::remove`], enhancing clarity and consistency. This change aligns with Rust API guidelines and improves the overall usability of the SLRU cache policy documentation.
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.
This commit introduces a breaking change by replacing multiple cache traits (
ReadOnlyCache,CoreCache,MutableCache,FifoCacheTrait,LruCacheTrait,LfuCacheTrait,LrukCacheTrait) with a singleCache<K, V>trait. Five optional capability traits have been added:EvictingCache,VictimInspectable,RecencyTracking,FrequencyTracking, andHistoryTracking. Policy-specific methods are now inherent methods, and thebuilder::Cachehas been renamed tobuilder::DynCacheto avoid naming collisions. All cache policies have been updated to implement the newCache<K, V>trait, ensuring universal support forpeekandremoveoperations.Description
Related Issue
Fixes #
Type of Change
How Has This Been Tested?
Test environment:
Checklist
cargo fmtandcargo clippycargo test)Screenshots (if applicable)
Additional Notes