disable cache when CacheLoadStyle::NONE (#152)

This commit is contained in:
Nathan Nichols
2022-05-15 19:29:05 -05:00
committed by GitHub
parent e7204a513a
commit 3f47b85e3b
3 changed files with 18 additions and 0 deletions

View File

@@ -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();