cache-tools 0.1.0
In-memory cache whose entries expire after a time to live, with an injectable clock and optional size limit
Install
cargo add cache-tools --registry rupm
In Ruststudio: Packages, search for cache-tools, Install.
Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-22.
Versions
- 0.1.0 2026-11-22
README
# cache-tools
In-memory cache whose entries expire after a time to live, with an injectable clock and optional size limit
Add it with `rupm add cache-tools` (or `cargo add cache-tools --registry rupm`).
```rust
use cache_tools::{ManualClock, TtlCache};
use std::time::Duration;
let clock = ManualClock::new();
let mut cache = TtlCache::with_clock(Duration::from_secs(60), clock.clone());
cache.insert("token", 42);
assert_eq!(cache.get(&"token"), Some(&42));
clock.advance(Duration::from_secs(61));
assert_eq!(cache.get(&"token"), None); // expired
```