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