3 releases

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

#1203 in Data structures

Download history 378/week @ 2024-10-13 89/week @ 2024-10-20 115/week @ 2024-10-27 245/week @ 2024-11-03 230/week @ 2024-11-10 247/week @ 2024-11-17 175/week @ 2024-11-24 289/week @ 2024-12-01 302/week @ 2024-12-08 325/week @ 2024-12-15 466/week @ 2024-12-22 206/week @ 2024-12-29 380/week @ 2025-01-05 113/week @ 2025-01-12 123/week @ 2025-01-19 112/week @ 2025-01-26

805 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