Crates.io | wtinylfu |
lib.rs | wtinylfu |
version | 0.2.0 |
source | src |
created_at | 2022-05-28 09:56:55.246142 |
updated_at | 2024-07-25 14:25:41.79274 |
description | An implementation of W-TinyLFU cache |
homepage | |
repository | https://git.sr.ht/~asyncth/wtinylfu |
max_upload_size | |
id | 595670 |
size | 23,765 |
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.
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"));
}
Contributions are welcome! Currently this project is hosted both on GitHub and sr.ht. Contributions from either of these are accepted. Please follow contributing guidelines.