3 releases

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

#944 in Data structures

Download history 152/week @ 2024-05-06 24/week @ 2024-05-13 31/week @ 2024-05-20 31/week @ 2024-05-27 18/week @ 2024-06-03 108/week @ 2024-06-10 21/week @ 2024-06-17 50/week @ 2024-06-24 17/week @ 2024-07-01 28/week @ 2024-07-08 10/week @ 2024-07-29 2/week @ 2024-08-05 165/week @ 2024-08-12 42/week @ 2024-08-19

219 downloads per month

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