#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

#201 in Caching

Download history 10/week @ 2024-02-19 5/week @ 2024-02-26 7/week @ 2024-03-11 187/week @ 2024-04-01

194 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