#cache #replace #strategy #count #capacity #happen #fbr

fbr_cache

A cache with frequency-based replacement strategy

2 releases

0.1.1 Jul 4, 2022
0.1.0 Jul 3, 2022

#263 in Caching

MIT/Apache

21KB
501 lines

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);

Dependencies

~390KB