20 #ifndef RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED
21 #define RIPPLE_NODESTORE_DATABASENODEIMP_H_INCLUDED
23 #include <ripple/basics/TaggedCache.h>
24 #include <ripple/basics/chrono.h>
25 #include <ripple/nodestore/Database.h>
44 :
Database(scheduler, readThreads, config, j)
48 if (config.
exists(
"cache_size"))
50 cacheSize = get<int>(config,
"cache_size");
51 if (cacheSize.
value() < 0)
53 Throw<std::runtime_error>(
54 "Specified negative value for cache_size");
57 if (config.
exists(
"cache_age"))
59 cacheAge = get<int>(config,
"cache_age");
60 if (cacheAge.
value() < 0)
62 Throw<std::runtime_error>(
63 "Specified negative value for cache_age");
66 if (cacheSize || cacheAge)
68 if (!cacheSize || *cacheSize == 0)
70 if (!cacheAge || *cacheAge == 0)
72 cache_ = std::make_shared<TaggedCache<uint256, NodeObject>>(
Holds a collection of configuration values.
std::shared_ptr< Backend > backend_
std::int32_t getWriteLoad() const override
Retrieve the estimated number of pending write operations.
void importDatabase(Database &source) override
Import objects from another database.
Persistency layer for NodeObject.
NodeObjectType
The types of node objects.
std::shared_ptr< NodeObject > fetchNodeObject(uint256 const &hash, std::uint32_t, FetchReport &fetchReport) override
bool exists(std::string const &name) const
Returns true if a key with the given name exists.
Contains information about a fetch operation.
std::optional< Backend::Counters< std::uint64_t > > getCounters() const override
Retrieve backend read and write stats.
Stopwatch & stopwatch()
Returns an instance of a wall clock.
void for_each(std::function< void(std::shared_ptr< NodeObject >)> f) override
Visit every object in the database This is usually called during import.
void importInternal(Backend &dstBackend, Database &srcDB)
std::shared_ptr< TaggedCache< uint256, NodeObject > > cache_
A generic endpoint for log messages.
Scheduling for asynchronous backend activity.
DatabaseNodeImp & operator=(DatabaseNodeImp const &)=delete
bool isSameDB(std::uint32_t, std::uint32_t) override
void store(NodeObjectType type, Blob &&data, uint256 const &hash, std::uint32_t) override
Store the object.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
virtual bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger)=0
Store a ledger from a different database.
bool storeLedger(std::shared_ptr< Ledger const > const &srcLedger) override
Store a ledger from a different database.
void sweep() override
Remove expired entries from the positive and negative caches.
std::vector< std::shared_ptr< NodeObject > > fetchBatch(std::vector< uint256 > const &hashes)
DatabaseNodeImp(Scheduler &scheduler, int readThreads, std::shared_ptr< Backend > backend, Section const &config, beast::Journal j)
std::string getName() const override
Retrieve the name associated with this backend.