timedmap
A more or less port of my package timedmap - originally written in Go - but for Rust!
timedmap
provides a thread-safe hash map with expiring key-value pairs and
automatic cleanup mechnaisms for popular async runtimes.
Basic Example
use TimedMap;
use Duration;
let tm = new;
tm.insert;
tm.insert;
tm.insert;
assert_eq!;
assert_eq!;
assert_eq!;
sleep;
assert_eq!;
assert_eq!;
assert_eq!;
sleep;
assert_eq!;
assert_eq!;
assert_eq!;
Cleanup Example
You can use the [Cleanup
] trait to automatically clean up
expired key-value pairs in given time intervals using popular
async runtimes.
Currently, only implementations for
tokio
andactix-rt
are available. Implentations for other popular runtimes are planned in the future. If you want to contribute an implementation, feel free to create a pull request. 😄
use ;
use Duration;
use Arc;
let tm = new;
tm.insert;
let cancel = start_cycle;
cancel;