3#include <xrpl/basics/TaggedCache.h>
4#include <xrpl/basics/chrono.h>
5#include <xrpl/config/BasicConfig.h>
6#include <xrpl/config/Constants.h>
7#include <xrpl/nodestore/Database.h>
31 cacheSize = get<int>(config, Keys::kCacheSize);
32 if (cacheSize.value() < 0)
33 Throw<std::runtime_error>(
"Specified negative value for cache_size");
38 cacheAge = get<int>(config, Keys::kCacheAge);
39 if (cacheAge.value() < 0)
40 Throw<std::runtime_error>(
"Specified negative value for cache_age");
45 cache_ = std::make_shared<TaggedCache<uint256, NodeObject>>(
47 cacheSize.value_or(0),
48 std::chrono::minutes(cacheAge.value_or(0)),
55 "xrpl::NodeStore::DatabaseNodeImp::DatabaseNodeImp : non-null "
A generic endpoint for log messages.
std::string getName() const override
Retrieve the name associated with this backend.
std::shared_ptr< TaggedCache< uint256, NodeObject > > cache_
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
void forEach(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
std::shared_ptr< Backend > backend_
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport, bool duplicate) override
void sweep() override
Remove expired entries from the positive and negative caches.
void asyncFetch(uint256 const &hash, std::uint32_t ledgerSeq, std::function< void(std::shared_ptr< NodeObject > const &)> &&callback) override
Fetch an object without waiting.
bool isSameDB(std::uint32_t, std::uint32_t) override
DatabaseNodeImp(Scheduler &scheduler, int readThreads, std::shared_ptr< Backend > backend, Section const &config, beast::Journal j)
~DatabaseNodeImp() override
DatabaseNodeImp(DatabaseNodeImp const &)=delete
DatabaseNodeImp & operator=(DatabaseNodeImp const &)=delete
void importDatabase(Database &source) override
Import objects from another database.
void importInternal(Backend &dstBackend, Database &srcDB)
Scheduling for asynchronous backend activity.
Holds a collection of configuration values.
bool exists(std::string const &name) const
Returns true if a key with the given name exists.
NodeObjectType
The types of node objects.
std::vector< unsigned char > Blob
Storage for linear binary data.
static constexpr auto kCacheSize
static constexpr auto kCacheAge
Contains information about a fetch operation.