Skip to content

feat: introduce TTL support with ExpiringCache decorator#132

Merged
TKorr merged 2 commits into
mainfrom
feat/ttl-support
May 13, 2026
Merged

feat: introduce TTL support with ExpiringCache decorator#132
TKorr merged 2 commits into
mainfrom
feat/ttl-support

Conversation

@TKorr

@TKorr TKorr commented May 13, 2026

Copy link
Copy Markdown
Contributor
  • 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.

Description

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to change)
  • 📝 Documentation update
  • 🔧 Refactoring (no functional changes)
  • ⚡ Performance improvement
  • 🧪 Test addition or modification

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Manual testing

Test environment:

  • OS:
  • Rust version:

Checklist

  • My code follows the project's coding standards
  • I have run cargo fmt and cargo clippy
  • I have added tests for my changes
  • All new and existing tests pass (cargo test)
  • I have updated the documentation as needed
  • I have added an entry to CHANGELOG.md (if applicable)

Screenshots (if applicable)

Additional Notes

TKorr added 2 commits May 13, 2026 20:35
- 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.
@TKorr TKorr merged commit c5b9f5c into main May 13, 2026
19 checks passed
@TKorr TKorr deleted the feat/ttl-support branch May 13, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant