Crates.io | expiremap |
lib.rs | expiremap |
version | 0.1.0-beta.0 |
source | src |
created_at | 2024-10-27 15:53:40.049101 |
updated_at | 2024-10-27 15:53:40.049101 |
description | A simple Key-Value map where each value has a custom expiry time. |
homepage | |
repository | https://github.com/MalstromDevelopers/expiremap |
max_upload_size | |
id | 1424717 |
size | 9,351 |
NOTE: This is a very early and lean beta version
A simple Key-Value map where each item has an associated expiry time.
Calling .expire(<time>)
on the map removes all items which are past their expiry (<=
The expiry time does not have to be based on actual time, anything implementing the Ord
trait can be used,
making this map useful for usage with logical timestamps.
use expiremap::ExpireMap;
let mut map = ExpireMap::new();
// key, value, expiry time
map.insert("foo", "bar", 1);
map.insert("baz", "bar", 3);
// removes all items with expiry
map.expire(2)
assert!(map.get("foo").is_none());
assert!(map.get("baz").is_some());