Crate expiringmap

Source
Expand description

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

Structsยง

ExpiringMap
A wrapper around HashMap which adds TTLs
ExpiringSet
A set version of ExpiringMap. Sets V to ()
ExpiryValue
A struct to contain a value and its expiry information