3 releases

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

#1114 in Data structures

Download history 198/week @ 2024-09-16 126/week @ 2024-09-23 99/week @ 2024-09-30 217/week @ 2024-10-07 386/week @ 2024-10-14 65/week @ 2024-10-21 142/week @ 2024-10-28 238/week @ 2024-11-04 232/week @ 2024-11-11 233/week @ 2024-11-18 252/week @ 2024-11-25 229/week @ 2024-12-02 290/week @ 2024-12-09 322/week @ 2024-12-16 467/week @ 2024-12-23 179/week @ 2024-12-30

1,289 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