9 releases (5 breaking)
0.6.0 | Jan 23, 2023 |
---|---|
0.5.0 | Jan 21, 2023 |
0.4.1 | Sep 21, 2021 |
0.3.0 | Sep 15, 2021 |
0.1.0 | Apr 20, 2021 |
#221 in Caching
14KB
283 lines
freqache
A thread-safe Rust LFU cache which supports iteration.
Example:
use freqache::LFUCache;
let mut cache = LFUCache::new();
cache.insert("key1");
cache.insert("key2");
cache.insert("key3");
cache.insert("key2");
for key in cache.iter() {
println!("key: {}", key);
}
lib.rs
:
A hash map ordered by access frequency.
Example:
use freqache::LFUCache;
const CACHE_SIZE: usize = 10;
let mut cache = LFUCache::new();
cache.insert("one", 1);
cache.insert("two", 2);
// ...
for (key, value) in cache.iter() {
println!("{}: {}", key, value);
}
while cache.len() > CACHE_SIZE {
cache.pop();
}