Crate freqache[−][src]
A weighted, thread-safe, futures-aware least-frequently-used cache.
LFUCache
does not provide a default eviction policy, but a callback and traversal method
which allow the developer to implement their own.
Example:
use freqache::{Entry, LFUCache}; #[derive(Clone)] struct Item; impl Entry for Item { fn weight() -> u64 { 1 } } struct Evict; let (tx, rx) = std::sync::mpsc::channel(); let mut cache = LFUCache::new(100, || { tx.send(Evict); }); cache.insert("key", Item); while rx.recv_timeout(Duration::default()).is_ok() { cache.evict(|key, value| { // maybe backup the contents of the entry here futures::future::ready(Result::<bool, String>::Ok(true)) }); }
Structs
LFUCache | A weighted, thread-safe, futures-aware least-frequently-used cache |
Traits
Entry | An |