Crates.io | cachemap2 |
lib.rs | cachemap2 |
version | 0.3.0 |
source | src |
created_at | 2023-03-21 13:22:39.917222 |
updated_at | 2024-01-19 17:45:15.191881 |
description | A concurrent insert-only hashmap for caching values |
homepage | https://github.com/afranchuk/cachemap2 |
repository | |
max_upload_size | |
id | 816178 |
size | 18,026 |
CacheMap is a data structure for concurrently caching values.
The cache
function will look up a value in the map, or generate and store a new one using the
provided function.
This is a updated and maintained fork of hclarke/cachemap.
use cachemap::CacheMap;
let m = CacheMap::new();
let fst = m.cache("key", || 5u32);
let snd = m.cache("key", || 7u32);
assert_eq!(*fst, *snd);
assert_eq!(*fst, 5u32);
&CacheMap<K,V>
rather than &mut CacheMap<K,V>
).dashmap
feature, which uses dashmap
internally and allows:
Arc<V>
pointers, in case values need to outlive the map, andArc<V>
directly, allowing unsized values, and re-using Arc<V>
s from elsewhere.abi_stable
feature which will derive abi_stable::StableAbi
on the type.