1#ifndef XRPL_BASICS_TAGGEDCACHE_H_INCLUDED 
    2#define XRPL_BASICS_TAGGEDCACHE_H_INCLUDED 
    4#include <xrpl/basics/IntrusivePointer.h> 
    5#include <xrpl/basics/Log.h> 
    6#include <xrpl/basics/SharedWeakCachePointer.ipp> 
    7#include <xrpl/basics/UnorderedContainers.h> 
    8#include <xrpl/basics/hardened_hash.h> 
    9#include <xrpl/beast/clock/abstract_clock.h> 
   10#include <xrpl/beast/insight/Insight.h> 
   36    bool IsKeyCache = 
false,
 
   37    class SharedWeakUnionPointerType = SharedWeakCachePointer<T>,
 
   39    class Hash = hardened_hash<>,
 
   89    template <
class KeyComparable>
 
  119        SharedPointerType& data,
 
  120        R&& replaceCallback);
 
  125        SharedPointerType 
const& data);
 
  137    template <
class ReturnType = 
bool>
 
  142    template <
class ReturnType = 
bool>
 
  170    template <
class Handler>
 
  185        template <
class Handler>
 
  188            Handler 
const& handler,
 
  190            : 
hook(collector->make_hook(handler))
 
  191            , 
size(collector->make_gauge(prefix, 
"size"))
 
  192            , 
hit_rate(collector->make_gauge(prefix, 
"hit_rate"))
 
 
 
  246            return ptr && 
ptr.isStrong();
 
 
  251            return ptr.expired();
 
 
 
 
A generic endpoint for log messages.
 
typename Clock::time_point time_point
 
typename Clock::duration duration
 
A metric for measuring an integral value.
 
A reference to a handler for performing polled collection.
 
static std::shared_ptr< Collector > New()
 
void touch(clock_type::time_point const &now)
 
KeyOnlyEntry(clock_type::time_point const &last_access_)
 
clock_type::time_point last_access
 
ValueEntry(clock_type::time_point const &last_access_, shared_pointer_type const &ptr_)
 
shared_weak_combo_pointer_type ptr
 
clock_type::time_point last_access
 
void touch(clock_type::time_point const &now)
 
bool canonicalize(key_type const &key, SharedPointerType &data, R &&replaceCallback)
Replace aliased objects with originals.
 
bool touch_if_exists(KeyComparable const &key)
Refresh the last access time on a key if present.
 
bool canonicalize_replace_client(key_type const &key, SharedPointerType &data)
 
bool retrieve(key_type const &key, T &data)
 
bool del(key_type const &key, bool valid)
 
SharedPointerType fetch(key_type const &key)
 
clock_type & clock()
Return the clock associated with the cache.
 
SharedWeakUnionPointerType shared_weak_combo_pointer_type
 
SharedPointerType fetch(key_type const &digest, Handler const &h)
Fetch an item from the cache.
 
auto insert(key_type const &key, T const &value) -> std::enable_if_t<!IsKeyCache, ReturnType >
Insert the element into the container.
 
std::vector< key_type > getKeys() const
 
bool canonicalize_replace_cache(key_type const &key, SharedPointerType const &data)
 
std::size_t size() const
Returns the number of items in the container.
 
SharedPointerType shared_pointer_type
 
std::thread sweepHelper(clock_type::time_point const &when_expire, clock_type::time_point const &now, typename KeyOnlyCacheType::map_type &partition, SweptPointersVector &, std::atomic< int > &allRemovals, std::lock_guard< std::recursive_mutex > const &)
 
SharedPointerType initialFetch(key_type const &key, std::lock_guard< mutex_type > const &l)
 
std::thread sweepHelper(clock_type::time_point const &when_expire, clock_type::time_point const &now, typename KeyValueCacheType::map_type &partition, SweptPointersVector &stuffToSweep, std::atomic< int > &allRemovals, std::lock_guard< std::recursive_mutex > const &)
 
std::conditional< IsKeyCache, KeyOnlyEntry, ValueEntry >::type Entry
 
double rate() const
Returns the fraction of cache hits.
 
auto insert(key_type const &key) -> std::enable_if_t< IsKeyCache, ReturnType >
 
clock_type::duration const m_target_age
 
TaggedCache(std::string const &name, int size, clock_type::duration expiration, clock_type &clock, beast::Journal journal, beast::insight::Collector::ptr const &collector=beast::insight::NullCollector::New())
 
TER valid(STTx const &tx, ReadView const &view, AccountID const &src, beast::Journal j)
 
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
 
static Hasher::result_type digest(void const *data, std::size_t size) noexcept
 
beast::insight::Gauge size
 
beast::insight::Hook hook
 
beast::insight::Gauge hit_rate
 
Stats(std::string const &prefix, Handler const &handler, beast::insight::Collector::ptr const &collector)