3 releases

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

#1200 in Data structures

Download history 257/week @ 2024-11-14 127/week @ 2024-11-21 305/week @ 2024-11-28 276/week @ 2024-12-05 314/week @ 2024-12-12 355/week @ 2024-12-19 335/week @ 2024-12-26 374/week @ 2025-01-02 253/week @ 2025-01-09 85/week @ 2025-01-16 80/week @ 2025-01-23 170/week @ 2025-01-30 269/week @ 2025-02-06 362/week @ 2025-02-13 217/week @ 2025-02-20 201/week @ 2025-02-27

1,091 downloads per month
Used in syd

Apache-2.0 OR MIT

14KB
305 lines

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());
}

lib.rs:

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());

No runtime deps