Crate freqache

source ·
Expand description

A thread-safe set which provides an Iterator ordered by access frequency.

Example:

use freqache::LFUCache;

const CACHE_SIZE: usize = 10;

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);
}

while cache.len() > CACHE_SIZE {
    cache.pop();
}

Structs

A weighted, thread-safe least-frequently-used cache