#cache #lru #lfu #tinylfu #w-tinylfu

wtinylfu

An implementation of W-TinyLFU cache

1 unstable release

0.1.0 May 28, 2022

#536 in Caching

Download history 1/week @ 2023-06-07 1/week @ 2023-06-14 1/week @ 2023-06-21 1/week @ 2023-06-28 35/week @ 2023-07-05 32/week @ 2023-07-12 74/week @ 2023-07-19 5/week @ 2023-07-26 38/week @ 2023-08-02 12/week @ 2023-08-09 15/week @ 2023-08-16 53/week @ 2023-08-23 32/week @ 2023-08-30 89/week @ 2023-09-06 59/week @ 2023-09-13 39/week @ 2023-09-20

242 downloads per month

MIT license

19KB
487 lines

An implementation of W-TinyLFU cache

Implements W-TinyLFU cache as proposed in "TinyLFU: A Highly Efficient Cache Admission Policy" paper using only safe Rust. The API of this crate is meant to be similar to the API of lru crate.

Example usage

use wtinylfu::WTinyLfuCache;

fn main() {
    let mut cache = WTinyLfuCache::new(2, 10);
    cache.push(1, "one");
    cache.push(2, "two");
    assert_eq!(cache.get(&1), Some(&"one"));
    assert_eq!(cache.get(&2), Some(&"two"));
}

Contributing

Contributions are welcome! Currently this project is hosted both on GitHub and sr.ht. Contributions from either of these are accepted.

Dependencies

~1MB
~20K SLoC