Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
data::LedgerCacheInterface Class Referenceabstract

Cache for an entire ledger. More...

#include <LedgerCacheInterface.hpp>

Inheritance diagram for data::LedgerCacheInterface:

Public Member Functions

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

Detailed Description

Cache for an entire ledger.

Member Function Documentation

◆ get()

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

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

Implemented in data::LedgerCache.

◆ getDeleted()

virtual std::optional< Blob > data::LedgerCacheInterface::getDeleted ( ripple::uint256 const & key,
uint32_t seq ) const
pure virtual

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

Implemented in data::LedgerCache.

◆ getObjectHitRate()

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

Implemented in data::LedgerCache.

◆ getPredecessor()

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

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

Implemented in data::LedgerCache.

◆ getSuccessor()

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

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

Implemented in data::LedgerCache.

◆ getSuccessorHitRate()

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

Implemented in data::LedgerCache.

◆ isDisabled()

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

Implemented in data::LedgerCache.

◆ isFull()

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

Implemented in data::LedgerCache.

◆ latestLedgerSequence()

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

Implemented in data::LedgerCache.

◆ setDisabled()

virtual void data::LedgerCacheInterface::setDisabled ( )
pure virtual

Disables the cache.

Implemented in data::LedgerCache.

◆ setFull()

virtual void data::LedgerCacheInterface::setFull ( )
pure virtual

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

Implemented in data::LedgerCache.

◆ size()

virtual size_t data::LedgerCacheInterface::size ( ) const
pure virtual
Returns
The total size of the cache.

Implemented in data::LedgerCache.

◆ update() [1/2]

virtual void data::LedgerCacheInterface::update ( std::vector< etlng::model::Object > const & objs,
uint32_t seq )
pure virtual

Update the cache with new ledger objects.

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

Implemented in data::LedgerCache.

◆ update() [2/2]

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

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

Implemented in data::LedgerCache.

◆ waitUntilCacheContainsSeq()

virtual void data::LedgerCacheInterface::waitUntilCacheContainsSeq ( uint32_t seq)
pure virtual

Waits until the cache contains a specific sequence.

Parameters
seqThe sequence to wait for

Implemented in data::LedgerCache.


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