typedcache 0.2.1

Concurrent-safe typedcache with expiration capabilities.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use std::time::Duration;

use typedcache::typed::TypedMap;

#[derive(Debug, Clone, Eq, PartialEq, Hash)]
pub struct TestKey(usize);

impl TypedMap for TestKey {
    type Value = TestValue;
}
pub struct TestValue(usize);

#[tokio::test]
async fn not_found_add() {
    let cache = typedcache::cache("test".into());
    assert!(cache.not_found_add(TestKey(1), Duration::ZERO, TestValue(1)));
    assert!(!cache.not_found_add(TestKey(1), Duration::ZERO, TestValue(1)));
}