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

Cache for an entire ledger. More...

#include <LedgerCache.hpp>

Inheritance diagram for data::LedgerCache:
Collaboration diagram for data::LedgerCache:

Public Member Functions

void update (std::vector< LedgerObject > const &objs, uint32_t seq, bool isBackground) override
 Update the cache with new ledger objects.
 
void update (std::vector< etlng::model::Object > const &objs, uint32_t seq) override
 Update the cache with new ledger objects.
 
std::optional< Blob > get (ripple::uint256 const &key, uint32_t seq) const override
 Fetch a cached object by its key and sequence number.
 
std::optional< Blob > getDeleted (ripple::uint256 const &key, uint32_t seq) const override
 Fetch a recently deleted object by its key and sequence number.
 
std::optional< LedgerObjectgetSuccessor (ripple::uint256 const &key, uint32_t seq) const override
 Gets a cached successor.
 
std::optional< LedgerObjectgetPredecessor (ripple::uint256 const &key, uint32_t seq) const override
 Gets a cached predcessor.
 
void setDisabled () override
 Disables the cache.
 
bool isDisabled () const override
 
void setFull () override
 Sets the full flag to true.
 
uint32_t latestLedgerSequence () const override
 
bool isFull () const override
 
size_t size () const override
 
float getObjectHitRate () const override
 
float getSuccessorHitRate () const override
 
void waitUntilCacheContainsSeq (uint32_t seq) override
 Waits until the cache contains a specific sequence.
 
- Public Member Functions inherited from data::LedgerCacheInterface
 LedgerCacheInterface (LedgerCacheInterface &&)=delete
 
 LedgerCacheInterface (LedgerCacheInterface const &)=delete
 
LedgerCacheInterfaceoperator= (LedgerCacheInterface &&)=delete
 
LedgerCacheInterfaceoperator= (LedgerCacheInterface const &)=delete
 

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
overridevirtual

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

Implements data::LedgerCacheInterface.

◆ getDeleted()

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

Fetch a recently deleted object by its key and sequence number.

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

Implements data::LedgerCacheInterface.

◆ getObjectHitRate()

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

Implements data::LedgerCacheInterface.

◆ getPredecessor()

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

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

Implements data::LedgerCacheInterface.

◆ getSuccessor()

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

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

Implements data::LedgerCacheInterface.

◆ getSuccessorHitRate()

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

Implements data::LedgerCacheInterface.

◆ isDisabled()

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

Implements data::LedgerCacheInterface.

◆ isFull()

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

Implements data::LedgerCacheInterface.

◆ latestLedgerSequence()

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

Implements data::LedgerCacheInterface.

◆ setDisabled()

void data::LedgerCache::setDisabled ( )
overridevirtual

Disables the cache.

Implements data::LedgerCacheInterface.

◆ setFull()

void data::LedgerCache::setFull ( )
overridevirtual

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).

Implements data::LedgerCacheInterface.

◆ size()

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

Implements data::LedgerCacheInterface.

◆ update() [1/2]

void data::LedgerCache::update ( std::vector< etlng::model::Object > const & objs,
uint32_t seq )
overridevirtual

Update the cache with new ledger objects.

Parameters
objsThe ledger objects to update cache with
seqThe sequence to update cache for

Implements data::LedgerCacheInterface.

◆ update() [2/2]

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

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

Implements data::LedgerCacheInterface.

◆ waitUntilCacheContainsSeq()

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

Waits until the cache contains a specific sequence.

Parameters
seqThe sequence to wait for

Implements data::LedgerCacheInterface.


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