xrpld
Loading...
Searching...
No Matches
xrpl::detail::BasicFullBelowCache Class Reference

Remembers which tree keys have all descendants resident. More...

#include <FullBelowCache.h>

Collaboration diagram for xrpl::detail::BasicFullBelowCache:

Public Types

using key_type = uint256
using clock_type = CacheType::clock_type

Public Member Functions

 BasicFullBelowCache (std::string const &name, clock_type &clock, beast::Journal j, beast::insight::Collector::ptr const &collector=beast::insight::NullCollector::make(), std::size_t targetSize=kDefaultCacheTargetSize, std::chrono::seconds expiration=std::chrono::minutes{2})
 Construct the cache.
clock_typeclock ()
 Return the clock associated with the cache.
std::size_t size () const
 Return the number of elements in the cache.
void sweep ()
 Remove expired cache items.
bool touchIfExists (key_type const &key)
 Refresh the last access time of an item, if it exists.
void insert (key_type const &key)
 Insert a key into the cache.
std::uint32_t getGeneration (void) const
 generation determines whether cached entry is valid
void clear ()
void reset ()

Static Public Attributes

static constexpr auto kDefaultCacheTargetSize = 0

Private Types

using CacheType = KeyCache

Private Attributes

CacheType cache_
std::atomic< std::uint32_tgen_

Detailed Description

Remembers which tree keys have all descendants resident.

This optimizes the process of acquiring a complete tree.

Definition at line 19 of file FullBelowCache.h.

Member Typedef Documentation

◆ CacheType

Definition at line 22 of file FullBelowCache.h.

◆ key_type

◆ clock_type

Constructor & Destructor Documentation

◆ BasicFullBelowCache()

xrpl::detail::BasicFullBelowCache::BasicFullBelowCache ( std::string const & name,
clock_type & clock,
beast::Journal j,
beast::insight::Collector::ptr const & collector = beast::insight::NullCollector::make(),
std::size_t targetSize = kDefaultCacheTargetSize,
std::chrono::seconds expiration = std::chrono::minutes{2} )

Construct the cache.

Parameters
nameA label for diagnostics and stats reporting.
collectorThe collector to use for reporting stats.
targetSizeThe cache target size.
targetExpirationSecondsThe expiration time for items.

Definition at line 37 of file FullBelowCache.h.

Member Function Documentation

◆ clock()

clock_type & xrpl::detail::BasicFullBelowCache::clock ( )

Return the clock associated with the cache.

Definition at line 50 of file FullBelowCache.h.

◆ size()

std::size_t xrpl::detail::BasicFullBelowCache::size ( ) const

Return the number of elements in the cache.

Thread safety: Safe to call from any thread.

Definition at line 60 of file FullBelowCache.h.

◆ sweep()

void xrpl::detail::BasicFullBelowCache::sweep ( )

Remove expired cache items.

Thread safety: Safe to call from any thread.

Definition at line 70 of file FullBelowCache.h.

◆ touchIfExists()

bool xrpl::detail::BasicFullBelowCache::touchIfExists ( key_type const & key)

Refresh the last access time of an item, if it exists.

Thread safety: Safe to call from any thread.

Parameters
keyThe key to refresh.
Returns
true If the key exists.

Definition at line 82 of file FullBelowCache.h.

◆ insert()

void xrpl::detail::BasicFullBelowCache::insert ( key_type const & key)

Insert a key into the cache.

If the key already exists, the last access time will still be refreshed. Thread safety: Safe to call from any thread.

Parameters
keyThe key to insert.

Definition at line 95 of file FullBelowCache.h.

◆ getGeneration()

std::uint32_t xrpl::detail::BasicFullBelowCache::getGeneration ( void ) const

generation determines whether cached entry is valid

Definition at line 102 of file FullBelowCache.h.

◆ clear()

void xrpl::detail::BasicFullBelowCache::clear ( )

Definition at line 108 of file FullBelowCache.h.

◆ reset()

void xrpl::detail::BasicFullBelowCache::reset ( )

Definition at line 115 of file FullBelowCache.h.

Member Data Documentation

◆ kDefaultCacheTargetSize

auto xrpl::detail::BasicFullBelowCache::kDefaultCacheTargetSize = 0
staticconstexpr

Definition at line 25 of file FullBelowCache.h.

◆ cache_

CacheType xrpl::detail::BasicFullBelowCache::cache_
private

Definition at line 122 of file FullBelowCache.h.

◆ gen_

std::atomic<std::uint32_t> xrpl::detail::BasicFullBelowCache::gen_
private

Definition at line 123 of file FullBelowCache.h.