An LFU cache for Rust. This is an implementation of the algorithm described in this paper.
The LFUCache
struct is similar to a typical HashMap.
// Initialize cache with size 10
let mut cache: LFUCache<K, V> = LFUCache::new(10);
// Insertion
// Returns the old value if this key already existed
cache.insert(K, V) // -> Option<V>
// Retrieval
myValue = c.get(&K) // -> Option<&V>
// Removal
c.remove(&K) // Option<V>
$ cargo test --all