feat: introduce TTL support with ExpiringCache decorator#132
Merged
Conversation
- Added time-based expiration functionality through the `Expiring<C>` decorator, allowing caches to manage per-entry TTLs. - Implemented `Clock` trait and `MockClock` for time management, enabling deterministic testing. - Introduced `ExpirationIndex` for efficient deadline tracking and management of expired entries. - Updated `CacheBuilder` to support `DynExpiringCache` with default TTL configuration. - Added benchmarks to evaluate the overhead of the TTL decorator against a standard LRU cache. This implementation enhances the cache library's capabilities by allowing for more flexible cache management strategies, particularly in scenarios requiring time-based expiration.
- Updated doc comments in `builder.rs` to accurately reference the `CacheBuilder` module. - Refined documentation in `expiration_index.rs` to enhance clarity regarding the `LazyMinHeap` wrapper. - Adjusted comments in `expiring.rs` to simplify the description of ordering enforcement in the `purge_one` method. These changes improve the accuracy and readability of the documentation, ensuring users have a clearer understanding of the cache library's components and their interactions.
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.
Expiring<C>decorator, allowing caches to manage per-entry TTLs.Clocktrait andMockClockfor time management, enabling deterministic testing.ExpirationIndexfor efficient deadline tracking and management of expired entries.CacheBuilderto supportDynExpiringCachewith default TTL configuration.This implementation enhances the cache library's capabilities by allowing for more flexible cache management strategies, particularly in scenarios requiring time-based expiration.
Description
Related Issue
Fixes #
Type of Change
How Has This Been Tested?
Test environment:
Checklist
cargo fmtandcargo clippycargo test)Screenshots (if applicable)
Additional Notes