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

Manages asynchronous saving of ledger cache to a file. More...

#include <LedgerCacheSaver.hpp>

Public Member Functions

 LedgerCacheSaver (util::config::ClioConfigDefinition const &config, LedgerCacheInterface const &cache)
 Constructs a LedgerCacheSaver instance.
 ~LedgerCacheSaver ()
 Destructor that ensures the saving thread is properly joined.
void save ()
 Initiates an asynchronous save operation of the ledger cache.
void waitToFinish ()
 Waits for the saving thread to complete.

Detailed Description

Manages asynchronous saving of ledger cache to a file.

This class provides functionality to save the ledger cache to a file in a separate thread, allowing the main application to continue without blocking. The file path is configured through the application's configuration system.

Constructor & Destructor Documentation

◆ LedgerCacheSaver()

data::LedgerCacheSaver::LedgerCacheSaver ( util::config::ClioConfigDefinition const & config,
LedgerCacheInterface const & cache )

Constructs a LedgerCacheSaver instance.

Parameters
configThe configuration object containing the cache file path setting
cacheReference to the ledger cache interface to be saved

◆ ~LedgerCacheSaver()

data::LedgerCacheSaver::~LedgerCacheSaver ( )

Destructor that ensures the saving thread is properly joined.

Waits for any ongoing save operation to complete before destruction.

Member Function Documentation

◆ save()

void data::LedgerCacheSaver::save ( )

Initiates an asynchronous save operation of the ledger cache.

Spawns a new thread that saves the ledger cache to the configured file path. If no file path is configured, the operation is skipped. Logs the progress and result of the save operation.

◆ waitToFinish()

void data::LedgerCacheSaver::waitToFinish ( )

Waits for the saving thread to complete.

Blocks until the saving operation finishes if a thread is currently active. Safe to call multiple times or when no save operation is in progress.


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