#cache #eviction #frequently #used #least

freqache

A thread-safe LFU cache with iterator

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

#268 in Caching

Download history 5/week @ 2024-09-19 7/week @ 2024-09-26 1/week @ 2024-10-03

56 downloads per month

Apache-2.0

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

No runtime deps