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

Memory-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 MemoryConstrainedCache = Cache< Key, Value, InsertionPolicy, EvictionPolicy, policy::ConstraintMemory, 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 = MemoryConstrainedCache< 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 = MemoryConstrainedCache< 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 = MemoryConstrainedCache< Key, Value, policy::InsertionAlways, policy::bind< policy::EvictionGDSF, Cost >::template ttype, MeasureValue, MeasureKey, KeyHash, ThreadSafe >
 Custom-Cost Cache. More...
 

Detailed Description

Memory-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::memory::CustomCostCache = typedef MemoryConstrainedCache<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::memory::LRUCache = typedef MemoryConstrainedCache<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::memory::TinyLFUCache = typedef MemoryConstrainedCache<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)