mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-23 13:15:51 +00:00
disable cache when CacheLoadStyle::NONE (#152)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <backend/SimpleCache.h>
|
||||
namespace Backend {
|
||||
|
||||
uint32_t
|
||||
SimpleCache::latestLedgerSequence() const
|
||||
{
|
||||
@@ -13,6 +14,9 @@ SimpleCache::update(
|
||||
uint32_t seq,
|
||||
bool isBackground)
|
||||
{
|
||||
if (disabled_)
|
||||
return;
|
||||
|
||||
{
|
||||
std::unique_lock lck{mtx_};
|
||||
if (seq > latestSeq_)
|
||||
@@ -82,9 +86,18 @@ SimpleCache::get(ripple::uint256 const& key, uint32_t seq) const
|
||||
return {e->second.blob};
|
||||
}
|
||||
|
||||
void
|
||||
SimpleCache::setDisabled()
|
||||
{
|
||||
disabled_ = true;
|
||||
}
|
||||
|
||||
void
|
||||
SimpleCache::setFull()
|
||||
{
|
||||
if (disabled_)
|
||||
return;
|
||||
|
||||
full_ = true;
|
||||
std::unique_lock lck{mtx_};
|
||||
deletes_.clear();
|
||||
|
||||
@@ -21,6 +21,7 @@ class SimpleCache
|
||||
mutable std::shared_mutex mtx_;
|
||||
uint32_t latestSeq_ = 0;
|
||||
std::atomic_bool full_ = false;
|
||||
std::atomic_bool disabled_ = false;
|
||||
// temporary set to prevent background thread from writing already deleted
|
||||
// data. not used when cache is full
|
||||
std::unordered_set<ripple::uint256, ripple::hardened_hash<>> deletes_;
|
||||
@@ -45,6 +46,9 @@ public:
|
||||
std::optional<LedgerObject>
|
||||
getPredecessor(ripple::uint256 const& key, uint32_t seq) const;
|
||||
|
||||
void
|
||||
setDisabled();
|
||||
|
||||
void
|
||||
setFull();
|
||||
|
||||
|
||||
@@ -894,6 +894,7 @@ ReportingETL::loadCache(uint32_t seq)
|
||||
{
|
||||
if (cacheLoadStyle_ == CacheLoadStyle::NOT_AT_ALL)
|
||||
{
|
||||
backend_->cache().setDisabled();
|
||||
BOOST_LOG_TRIVIAL(warning) << "Cache is disabled. Not loading";
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user