#least #used #cache #frequently #eviction

freqache

A thread-safe LFU cache with iterator

9 releases (5 breaking)

Uses new Rust 2021

new 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

#70 in Caching

Download history 12/week @ 2022-10-07 11/week @ 2022-10-14 11/week @ 2022-10-21 13/week @ 2022-10-28 13/week @ 2022-11-04 15/week @ 2022-11-11 10/week @ 2022-11-18 5/week @ 2022-11-25 6/week @ 2022-12-02 13/week @ 2022-12-09 13/week @ 2022-12-16 14/week @ 2022-12-23 12/week @ 2022-12-30 29/week @ 2023-01-06 10/week @ 2023-01-13 62/week @ 2023-01-20

118 downloads per month
Used in 2 crates (via freqfs)

Apache-2.0

13KB
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