20 #ifndef RIPPLE_LEDGER_CACHEDSLES_H_INCLUDED
21 #define RIPPLE_LEDGER_CACHEDSLES_H_INCLUDED
23 #include <ripple/basics/chrono.h>
24 #include <ripple/beast/container/aged_unordered_map.h>
25 #include <ripple/protocol/STLedgerEntry.h>
43 template <
class Rep,
class Period>
65 template <
class Handler>
72 if (iter !=
map_.end())
84 auto const [it, inserted] =
map_.emplace(
digest, std::move(sle));
value_type fetch(digest_type const &digest, Handler const &h)
Fetch an item from the cache.
Stopwatch::duration timeToLive_
std::chrono::steady_clock clock_type
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
beast::aged_unordered_map< digest_type, value_type, Stopwatch::clock_type, hardened_hash< strong_hash > > map_
Caches SLEs by their digest.
void expire()
Discard expired entries.
CachedSLEs & operator=(CachedSLEs const &)=delete
double rate() const
Returns the fraction of cache hits.
Seed functor once per construction.
CachedSLEs(std::chrono::duration< Rep, Period > const &timeToLive, Stopwatch &clock)
Associative container where each element is also indexed by time.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
std::shared_ptr< SLE const > value_type
typename std::chrono::steady_clock ::duration duration
CachedSLEs(CachedSLEs const &)=delete