3 releases

0.1.2 Aug 13, 2024
0.1.1 May 8, 2024
0.1.0 Apr 14, 2024

#1616 in Data structures

Download history 250/week @ 2025-09-20 438/week @ 2025-09-27 357/week @ 2025-10-04 223/week @ 2025-10-11 284/week @ 2025-10-18 289/week @ 2025-10-25 365/week @ 2025-11-01 387/week @ 2025-11-08 159/week @ 2025-11-15 142/week @ 2025-11-22 445/week @ 2025-11-29 211/week @ 2025-12-06 318/week @ 2025-12-13 169/week @ 2025-12-20 204/week @ 2025-12-27 307/week @ 2026-01-03

1,004 downloads per month
Used in 2 crates

Apache-2.0 OR MIT

14KB
305 lines

ExpiringMap is a wrapper around HashMap that allows the specification of TTLs on entries. It does not support iteration.

use std::time::Duration;
use expiringmap::ExpiringMap;
let mut map = ExpiringMap::new();
map.insert("key", "value", Duration::from_millis(50));
std::thread::sleep(Duration::from_millis(60));
assert!(map.get(&"key").is_none());

expiringmap

A rust library implementing a TTL map.

use std::time::Duration;
use expiringmap::ExpiringMap;

fn main() {
    let mut map = ExpiringMap::new();
    map.insert("key", "value", Duration::from_millis(50));
    std::thread::sleep(Duration::from_millis(60));
    assert!(map.get(&"key").is_none());
}

No runtime deps