4#ifndef _Stroika_Foundation_Cache_SynchronizedLRUCache_h_
5#define _Stroika_Foundation_Cache_SynchronizedLRUCache_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
10#include <shared_mutex>
12#include "Stroika/Foundation/Cache/LRUCache.h"
38 template <
typename KEY,
typename VALUE,
typename KEY_EQUALS_COMPARER = equal_to<KEY>,
typename KEY_HASH_FUNCTION =
nullptr_t,
typename STATS_TYPE = Statistics::StatsType_DEFAULT>
43 using StatsType =
typename inherited::StatsType;
46 using KeyEqualsCompareFunctionType =
typename inherited::KeyEqualsCompareFunctionType;
52 template <
typename...
ARGS>
73 bool fHoldWriteLockDuringCacheFill{
false};
91 nonvirtual StatsType
GetStats ()
const;
115 nonvirtual
void clear ();
145 mutable shared_timed_mutex fMutex_;
160 template <
typename KEY,
typename VALUE,
typename STATS_TYPE = Statistics::StatsType_DEFAULT>
161 struct SynchronizedLRUCache_NoHash {
162 template <Common::IEqualsComparer<KEY> KEY_EQUALS_COMPARER = equal_to<KEY>>
179 template <
typename KEY,
typename VALUE,
typename STATS_TYPE = Statistics::StatsType_DEFAULT,
typename DEFAULT_KEY_EQUALS_COMPARER = equal_to<KEY>>
180 struct SynchronizedLRUCache_WithHash {
181 template <
typename KEY_HASH_FUNCTION = hash<KEY>>
188 template <
typename KEY_EQUALS_COMPARER,
typename KEY_HASH_FUNCTION = hash<KEY>>
207#include "SynchronizedLRUCache.inl"
LRUCache implements a simple least-recently-used caching strategy, with optional hashing (of keys) to...
simple wrapper on LRUCache (with the same API) - but internally synchronized in a way that is more pe...
nonvirtual optional< VALUE > Lookup(typename Common::ArgByValueType< KEY > key) const
nonvirtual void SetMaxCacheSize(size_t maxCacheSize)
nonvirtual KEY_HASH_FUNCTION GetKeyHashFunction() const
nonvirtual Containers::Mapping< KEY, VALUE > Elements() const
nonvirtual KeyEqualsCompareFunctionType GetKeyEqualsCompareFunction() const
nonvirtual size_t GetMaxCacheSize() const
nonvirtual VALUE LookupValue(typename Common::ArgByValueType< KEY > key, const function< VALUE(typename Common::ArgByValueType< KEY >)> &valueFetcher)
nonvirtual StatsType GetStats() const
nonvirtual size_t GetHashTableSize() const
nonvirtual void Add(typename Common::ArgByValueType< KEY > key, typename Common::ArgByValueType< VALUE > value)
static constexpr bool IsKeyedCache
conditional_t<(sizeof(CHECK_T)<=2 *sizeof(void *)) and is_trivially_copyable_v< CHECK_T >, CHECK_T, const CHECK_T & > ArgByValueType
This is an alias for 'T' - but how we want to pass it on stack as formal parameter.