4#ifndef _Stroika_Foundation_Cache_CallerStalenessCache_h_
5#define _Stroika_Foundation_Cache_CallerStalenessCache_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
9#include "Stroika/Foundation/Containers/Mapping.h"
32 template <
typename KEY>
37 struct CallerStalenessCache_Traits_DEFAULT {
40 static TimeStampType GetCurrentTimestamp ();
133 template <
typename KEY,
typename VALUE,
typename TIME_TRAITS = CallerStalenessCache_Traits_DEFAULT>
138 using TimeStampType =
typename TIME_TRAITS::TimeStampType;
143 using TimeStampDifferenceType =
typename TIME_TRAITS::TimeStampDifferenceType;
148 static TimeStampType GetCurrentTimestamp ();
169 nonvirtual
void ClearOlderThan (TimeStampType
t);
176 nonvirtual
void Clear ();
177 template <
typename K = KEY>
178 nonvirtual
void Clear (
const K& k)
190 template <
typename K = KEY>
211 template <
typename K = KEY>
222 template <
typename F,
typename K = KEY>
225 template <
typename K = KEY>
233 nonvirtual
void clear ();
238 TimeStampType fDataCapturedAt;
239 myVal_ (
VALUE&& v, TimeStampType
t)
250 struct MyLazyConditional_;
270#include "CallerStalenessCache.inl"
time_point< RealtimeClock, DurationSeconds > TimePointSeconds
TimePointSeconds is a simpler approach to chrono::time_point, which doesn't require using templates e...
chrono::duration< double > DurationSeconds
chrono::duration<double> - a time span (length of time) measured in seconds, but high precision.
static TimeStampType Ago(TimeStampDifferenceType backThisTime)
nonvirtual optional< VALUE > Lookup(TimeStampType staleIfOlderThan) const
nonvirtual VALUE LookupValue(TimeStampType staleIfOlderThan, const function< VALUE()> &cacheFiller)
nonvirtual void Add(Common::ArgByValueType< VALUE > v)
LRUCache implements a simple least-recently-used caching strategy, with optional hashing (of keys) to...
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.
AddReplaceMode
Mode flag to say if Adding to a container replaces, or if the first addition wins.