Cachemere
Modular Caching Library for C++
|
1 #ifndef CACHEMERE_INSERTION_TINYLFU_H
2 #define CACHEMERE_INSERTION_TINYLFU_H
6 #include "cachemere/item.h"
8 #include "detail/bloom_filter.h"
9 #include "detail/counting_bloom_filter.h"
11 namespace cachemere::policy {
38 template<
typename KeyType>
void on_cache_miss(
const KeyType& key);
62 const static uint32_t DEFAULT_CACHE_CARDINALITY = 2000;
66 uint32_t estimate_count_for_key(
const Key& key)
const;
69 template<
typename KeyType>
void touch_item(
const KeyType& key);
74 #include "insertion_tinylfu.hpp"
void on_cache_hit(const Key &key, const CacheItem &item)
Cache hit event handler.
Definition: insertion_tinylfu.hpp:9
void clear()
Clears the policy.
Definition: insertion_tinylfu.hpp:3
A wrapper for items stored in the cache.
Definition: item.h:10
Tiny Least Frequently Used (TinyLFU) insertion policy.
Definition: insertion_tinylfu.h:21
bool should_add(const Key &key)
Determines whether a given key should be inserted into the cache.
Definition: insertion_tinylfu.hpp:25
void on_cache_miss(const KeyType &key)
Cache miss event handler.
Definition: insertion_tinylfu.hpp:14
bool should_replace(const Key &victim, const Key &candidate)
Determines whether a given victim should be replaced by a given candidate.
Definition: insertion_tinylfu.hpp:30
void set_cardinality(uint32_t cardinality)
Set the cardinality of the policy.
Definition: insertion_tinylfu.hpp:19