rippled
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
ripple::detail::BasicFullBelowCache Class Reference

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

Collaboration diagram for ripple::detail::BasicFullBelowCache:
Collaboration graph
[legend]

Public Types

enum  { defaultCacheTargetSize = 0 }
 
using key_type = uint256
 
using clock_type = typename 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::New(), std::size_t target_size=defaultCacheTargetSize, std::chrono::seconds expiration=std::chrono::minutes{2})
 Construct the cache. More...
 
clock_typeclock ()
 Return the clock associated with the cache. More...
 
std::size_t size () const
 Return the number of elements in the cache. More...
 
void sweep ()
 Remove expired cache items. More...
 
bool touch_if_exists (key_type const &key)
 Refresh the last access time of an item, if it exists. More...
 
void insert (key_type const &key)
 Insert a key into the cache. More...
 
std::uint32_t getGeneration (void) const
 generation determines whether cached entry is valid More...
 
void clear ()
 
void reset ()
 

Private Types

using CacheType = KeyCache
 

Private Attributes

CacheType m_cache
 
std::atomic< std::uint32_tm_gen
 

Detailed Description

Remembers which tree keys have all descendants resident.

This optimizes the process of acquiring a complete tree.

Definition at line 38 of file FullBelowCache.h.

Member Typedef Documentation

◆ CacheType

Definition at line 41 of file FullBelowCache.h.

◆ key_type

Definition at line 46 of file FullBelowCache.h.

◆ clock_type

Definition at line 47 of file FullBelowCache.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
defaultCacheTargetSize 

Definition at line 44 of file FullBelowCache.h.

Constructor & Destructor Documentation

◆ BasicFullBelowCache()

ripple::detail::BasicFullBelowCache::BasicFullBelowCache ( std::string const &  name,
clock_type clock,
beast::Journal  j,
beast::insight::Collector::ptr const &  collector = beast::insight::NullCollector::New(),
std::size_t  target_size = defaultCacheTargetSize,
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 56 of file FullBelowCache.h.

Member Function Documentation

◆ clock()

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

Return the clock associated with the cache.

Definition at line 70 of file FullBelowCache.h.

◆ size()

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

Return the number of elements in the cache.

Thread safety: Safe to call from any thread.

Definition at line 80 of file FullBelowCache.h.

◆ sweep()

void ripple::detail::BasicFullBelowCache::sweep ( )

Remove expired cache items.

Thread safety: Safe to call from any thread.

Definition at line 90 of file FullBelowCache.h.

◆ touch_if_exists()

bool ripple::detail::BasicFullBelowCache::touch_if_exists ( 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 102 of file FullBelowCache.h.

◆ insert()

void ripple::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 115 of file FullBelowCache.h.

◆ getGeneration()

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

generation determines whether cached entry is valid

Definition at line 122 of file FullBelowCache.h.

◆ clear()

void ripple::detail::BasicFullBelowCache::clear ( )

Definition at line 128 of file FullBelowCache.h.

◆ reset()

void ripple::detail::BasicFullBelowCache::reset ( )

Definition at line 135 of file FullBelowCache.h.

Member Data Documentation

◆ m_cache

CacheType ripple::detail::BasicFullBelowCache::m_cache
private

Definition at line 142 of file FullBelowCache.h.

◆ m_gen

std::atomic<std::uint32_t> ripple::detail::BasicFullBelowCache::m_gen
private

Definition at line 143 of file FullBelowCache.h.