Crates.io | cachemap |
lib.rs | cachemap |
version | 0.1.0 |
source | src |
created_at | 2021-04-14 23:54:34.545596 |
updated_at | 2021-04-14 23:54:34.545596 |
description | A concurrent insert-only hashmap for caching values |
homepage | https://github.com/hclarke/cachemap |
repository | |
max_upload_size | |
id | 384270 |
size | 7,635 |
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
use cachemap::CacheMap;
let m = CacheMap::new();
let fst = m.cache("key", || 5u32).as_ref();
let snd = m.cache("key", || 7u32).as_ref();
assert_eq!(*fst, *snd);
assert_eq!(*fst, 5u32);
&CacheMap<K,V>
rather than &mut CacheMap<K,V>
)Arc<V>
pointers, in case values need to outlive the mapArc<V>
, allowing unsized values, and re-using Arc<V>
s from elsewhereA cache with a bad policy is another name for a memory leak
this map provides only one way to remove things from the cache: drop the entire map.