fbr_cache

Crates.iofbr_cache
lib.rsfbr_cache
version0.1.1
sourcesrc
created_at2022-07-03 20:20:31.975487
updated_at2022-07-04 05:57:57.21116
descriptionA cache with frequency-based replacement strategy
homepage
repositoryhttps://github.com/rkuhn/fbr_cache
max_upload_size
id618542
size20,931
Roland Kuhn (rkuhn)

documentation

https://docs.rs/fbr_cache/latest/fbr_cache

README

This crate implements a cache with frequency-based replacement strategy as described in the paper “Data Cache Management Using Frequency-Based Replacement” by John T. Robinson and Murthy V. Devarakonda, published in ACM SIGMETRICS 1990.

The configuration parameters of such a cache are:

  • capacity: the number of slots
  • A_max: the maximum average frequency count beyond which counts are aged. Aging will be performed roughly every A_max * capacity cache hits. 100 is a reasonable default.
  • C_max: the maximum frequency count for which eviction happens by count (above that: LRU). You will probably not need to tune this.

Example:

use fbr_cache::FbrCache;

let mut cache = FbrCache::new(1000);
cache.put(1, "hello");
cache.put(2, "world");

assert_eq!(cache.get(&1), Some(&"hello"));
assert_eq!(cache.len(), 2);
Commit count: 2

cargo fmt