https://github.com/asyncth/wtinylfu
An implementation of W-TinyLFU cache in Rust
https://github.com/asyncth/wtinylfu
cache lfu-cache rust tinylfu
Last synced: 5 months ago
JSON representation
An implementation of W-TinyLFU cache in Rust
- Host: GitHub
- URL: https://github.com/asyncth/wtinylfu
- Owner: asyncth
- License: mit
- Created: 2022-05-28T09:30:29.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-07-25T14:20:21.000Z (almost 2 years ago)
- Last Synced: 2024-07-25T16:18:29.187Z (almost 2 years ago)
- Topics: cache, lfu-cache, rust, tinylfu
- Language: Rust
- Homepage:
- Size: 15.6 KB
- Stars: 4
- Watchers: 1
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
> [!IMPORTANT]
> Given that this library is rarely updated and is quite barebones,
> consider using [Moka](https://crates.io/crates/moka) or
> [Mini Moka](https://crates.io/crates/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.
# 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
```rust
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"));
}
```