| Crates.io | wtinylfu |
| lib.rs | wtinylfu |
| version | 0.3.0 |
| created_at | 2022-05-28 09:56:55.246142+00 |
| updated_at | 2026-01-01 12:36:46.952273+00 |
| description | An implementation of W-TinyLFU cache |
| homepage | |
| repository | https://github.com/asyncth/wtinylfu |
| max_upload_size | |
| id | 595670 |
| size | 33,443 |
[!IMPORTANT] Given that this library is rarely updated and is quite barebones, consider using Moka or Mini Moka for caching. Strictly speaking, the README claims that these libraries do not currently implement W-TinyLFU, but rather use TinyLFU alone, but it probably should be good enough anyway.
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! Please follow contributing guidelines.