Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
data::LedgerCache Class Reference

Cache for an entire ledger. More...

#include <LedgerCache.hpp>

Public Member Functions

void update (std::vector< LedgerObject > const &objs, uint32_t seq, bool isBackground=false)
 Update the cache with new ledger objects.
 
std::optional< Blob > get (ripple::uint256 const &key, uint32_t seq) const
 Fetch a cached object by its key and sequence number.
 
std::optional< LedgerObjectgetSuccessor (ripple::uint256 const &key, uint32_t seq) const
 Gets a cached successor.
 
std::optional< LedgerObjectgetPredecessor (ripple::uint256 const &key, uint32_t seq) const
 Gets a cached predcessor.
 
void setDisabled ()
 Disables the cache.
 
bool isDisabled () const
 
void setFull ()
 Sets the full flag to true.
 
uint32_t latestLedgerSequence () const
 
bool isFull () const
 
size_t size () const
 
float getObjectHitRate () const
 
float getSuccessorHitRate () const
 
void waitUntilCacheContainsSeq (uint32_t seq)
 Waits until the cache contains a specific sequence.
 

Detailed Description

Cache for an entire ledger.

Member Function Documentation

◆ get()

std::optional< Blob > data::LedgerCache::get ( ripple::uint256 const & key,
uint32_t seq ) const

Fetch a cached object by its key and sequence number.

Parameters
keyThe key to fetch for
seqThe sequence to fetch for
Returns
If found in cache, will return the cached Blob; otherwise nullopt is returned

◆ getObjectHitRate()

float data::LedgerCache::getObjectHitRate ( ) const
Returns
A number representing the success rate of hitting an object in the cache versus missing it.

◆ getPredecessor()

std::optional< LedgerObject > data::LedgerCache::getPredecessor ( ripple::uint256 const & key,
uint32_t seq ) const

Gets a cached predcessor.

Note: This function always returns std::nullopt when isFull() returns false.

Parameters
keyThe key to fetch for
seqThe sequence to fetch for
Returns
If found in cache, will return the cached predcessor; otherwise nullopt is returned

◆ getSuccessor()

std::optional< LedgerObject > data::LedgerCache::getSuccessor ( ripple::uint256 const & key,
uint32_t seq ) const

Gets a cached successor.

Note: This function always returns std::nullopt when isFull() returns false.

Parameters
keyThe key to fetch for
seqThe sequence to fetch for
Returns
If found in cache, will return the cached successor; otherwise nullopt is returned

◆ getSuccessorHitRate()

float data::LedgerCache::getSuccessorHitRate ( ) const
Returns
A number representing the success rate of hitting a successor in the cache versus missing it.

◆ isDisabled()

bool data::LedgerCache::isDisabled ( ) const
Returns
true if the cache is disabled; false otherwise

◆ isFull()

bool data::LedgerCache::isFull ( ) const
Returns
true if the cache has all data for the most recent ledger; false otherwise

◆ latestLedgerSequence()

uint32_t data::LedgerCache::latestLedgerSequence ( ) const
Returns
The latest ledger sequence for which cache is available.

◆ setFull()

void data::LedgerCache::setFull ( )

Sets the full flag to true.

This is used when cache loaded in its entirety at startup of the application. This can be either loaded from DB, populated together with initial ledger download (on first run) or downloaded from a peer node (specified in config).

◆ size()

size_t data::LedgerCache::size ( ) const
Returns
The total size of the cache.

◆ update()

void data::LedgerCache::update ( std::vector< LedgerObject > const & objs,
uint32_t seq,
bool isBackground = false )

Update the cache with new ledger objects.

Parameters
objsThe ledger objects to update cache with
seqThe sequence to update cache for
isBackgroundShould be set to true when writing old data from a background thread

◆ waitUntilCacheContainsSeq()

void data::LedgerCache::waitUntilCacheContainsSeq ( uint32_t seq)

Waits until the cache contains a specific sequence.

Parameters
seqThe sequence to wait for

The documentation for this class was generated from the following files: