Packages / rupm

rs-net-cache-ttl 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 rs-net-cache-ttl --registry rupm

In Ruststudio: Packages, search for rs-net-cache-ttl, Install.

Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-23.

Versions

README

# rs-net-cache-ttl

In-memory cache whose entries expire after a time to live, with an injectable clock and optional size limit

Add it with `rupm add rs-net-cache-ttl` (or `cargo add rs-net-cache-ttl --registry rupm`).

```rust
use rs_net_cache_ttl::{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
```