Cachemere
Modular Caching Library for C++
Typedefs
cachemere::presets::count Namespace Reference

Count-constrained cache presets. More...

Typedefs

template<typename Key , typename Value , template< class, class, class > class InsertionPolicy, template< class, class, class > class EvictionPolicy, typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using CountConstrainedCache = Cache< Key, Value, InsertionPolicy, EvictionPolicy, policy::ConstraintCount, MeasureValue, MeasureKey, KeyHash, ThreadSafe >
 
template<typename Key , typename Value , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using LRUCache = CountConstrainedCache< Key, Value, policy::InsertionAlways, policy::EvictionLRU, MeasureValue, MeasureKey, KeyHash, ThreadSafe >
 Least-Recently-Used Cache. More...
 
template<typename Key , typename Value , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using TinyLFUCache = CountConstrainedCache< Key, Value, policy::InsertionTinyLFU, policy::EvictionSegmentedLRU, MeasureValue, MeasureKey, KeyHash, ThreadSafe >
 TinyLFU Cache. More...
 
template<typename Key , typename Value , typename Cost , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using CustomCostCache = CountConstrainedCache< Key, Value, policy::InsertionAlways, policy::bind< policy::EvictionGDSF, Cost >::template ttype, MeasureValue, MeasureKey, KeyHash, ThreadSafe >
 Custom-Cost Cache. More...
 

Detailed Description

Count-constrained cache presets.

Typedef Documentation

◆ CustomCostCache

template<typename Key , typename Value , typename Cost , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using cachemere::presets::count::CustomCostCache = typedef CountConstrainedCache<Key, Value, policy::InsertionAlways, policy::bind<policy::EvictionGDSF, Cost>::template ttype, MeasureValue, MeasureKey, KeyHash, ThreadSafe>

Custom-Cost Cache.

The use of this cache should be favored in scenarios where the cost of a cache miss varies greatly from one item to the next.

Template Parameters
KeyThe type of the key used for retrieving items.
ValueThe type of the items stored in the cache.
CostA functor taking a const Item<Key, Value>& returning the cost to load this item in cache.
MeasureValueA functor returning the size of a cache value.
MeasureKeyA functor returning the size of a cache key.
KeyHashA default-constructible callable type returning a hash of a key. Defaults to absl::Hash<Key>.
ThreadSafeWhether to protect this cache for concurrent access. (true by default)

◆ LRUCache

template<typename Key , typename Value , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using cachemere::presets::count::LRUCache = typedef CountConstrainedCache<Key, Value, policy::InsertionAlways, policy::EvictionLRU, MeasureValue, MeasureKey, KeyHash, ThreadSafe>

Least-Recently-Used Cache.

Uses a linked list to order items from hottest (most recently accessed) to coldest (least recently accessed).

Template Parameters
KeyThe type of the key used for retrieving items.
ValueThe type of the items stored in the cache.
MeasureValueA functor returning the size of a cache value.
MeasureKeyA functor returning the size of a cache key.
KeyHashA default-constructible callable type returning a hash of a key. Defaults to absl::Hash<Key>.
ThreadSafeWhether to protect this cache for concurrent access. (true by default)

◆ TinyLFUCache

template<typename Key , typename Value , typename MeasureValue = measurement::Size<Value>, typename MeasureKey = measurement::Size<Key>, typename KeyHash = absl::Hash<Key>, bool ThreadSafe = true>
using cachemere::presets::count::TinyLFUCache = typedef CountConstrainedCache<Key, Value, policy::InsertionTinyLFU, policy::EvictionSegmentedLRU, MeasureValue, MeasureKey, KeyHash, ThreadSafe>

TinyLFU Cache.

Uses a combination of frequency sketches to gather a decent estimate of the access frequency of most keys. Uses this estimate to decide which item should be held in cache over another.

Template Parameters
KeyThe type of the key used for retrieving items.
ValueThe type of the items stored in the cache.
MeasureValueA functor returning the size of a cache value.
MeasureKeyA functor returning the size of a cache key.
KeyHashA default-constructible callable type returning a hash of a key. Defaults to absl::Hash<Key>.
ThreadSafeWhether to protect this cache for concurrent access. (true by default)