rippled
|
Remembers which tree keys have all descendants resident. More...
Public Types | |
enum | { defaultCacheTargetSize = 0 } |
using | key_type = uint256 |
using | clock_type = typename CacheType::clock_type |
Public Member Functions | |
BasicFullBelowCache (std::string const &name, clock_type &clock, beast::Journal j, beast::insight::Collector::ptr const &collector=beast::insight::NullCollector::New(), std::size_t target_size=defaultCacheTargetSize, std::chrono::seconds expiration=std::chrono::minutes{2}) | |
Construct the cache. More... | |
clock_type & | clock () |
Return the clock associated with the cache. More... | |
std::size_t | size () const |
Return the number of elements in the cache. More... | |
void | sweep () |
Remove expired cache items. More... | |
bool | touch_if_exists (key_type const &key) |
Refresh the last access time of an item, if it exists. More... | |
void | insert (key_type const &key) |
Insert a key into the cache. More... | |
std::uint32_t | getGeneration (void) const |
generation determines whether cached entry is valid More... | |
void | clear () |
void | reset () |
Private Types | |
using | CacheType = KeyCache |
Private Attributes | |
CacheType | m_cache |
std::atomic< std::uint32_t > | m_gen |
Remembers which tree keys have all descendants resident.
This optimizes the process of acquiring a complete tree.
Definition at line 38 of file FullBelowCache.h.
|
private |
Definition at line 41 of file FullBelowCache.h.
Definition at line 46 of file FullBelowCache.h.
using ripple::detail::BasicFullBelowCache::clock_type = typename CacheType::clock_type |
Definition at line 47 of file FullBelowCache.h.
anonymous enum |
Enumerator | |
---|---|
defaultCacheTargetSize |
Definition at line 44 of file FullBelowCache.h.
ripple::detail::BasicFullBelowCache::BasicFullBelowCache | ( | std::string const & | name, |
clock_type & | clock, | ||
beast::Journal | j, | ||
beast::insight::Collector::ptr const & | collector = beast::insight::NullCollector::New() , |
||
std::size_t | target_size = defaultCacheTargetSize , |
||
std::chrono::seconds | expiration = std::chrono::minutes{2} |
||
) |
Construct the cache.
name | A label for diagnostics and stats reporting. |
collector | The collector to use for reporting stats. |
targetSize | The cache target size. |
targetExpirationSeconds | The expiration time for items. |
Definition at line 56 of file FullBelowCache.h.
clock_type& ripple::detail::BasicFullBelowCache::clock | ( | ) |
Return the clock associated with the cache.
Definition at line 70 of file FullBelowCache.h.
std::size_t ripple::detail::BasicFullBelowCache::size | ( | ) | const |
Return the number of elements in the cache.
Thread safety: Safe to call from any thread.
Definition at line 80 of file FullBelowCache.h.
void ripple::detail::BasicFullBelowCache::sweep | ( | ) |
Remove expired cache items.
Thread safety: Safe to call from any thread.
Definition at line 90 of file FullBelowCache.h.
bool ripple::detail::BasicFullBelowCache::touch_if_exists | ( | key_type const & | key | ) |
Refresh the last access time of an item, if it exists.
Thread safety: Safe to call from any thread.
key | The key to refresh. |
true
If the key exists. Definition at line 102 of file FullBelowCache.h.
void ripple::detail::BasicFullBelowCache::insert | ( | key_type const & | key | ) |
Insert a key into the cache.
If the key already exists, the last access time will still be refreshed. Thread safety: Safe to call from any thread.
key | The key to insert. |
Definition at line 115 of file FullBelowCache.h.
std::uint32_t ripple::detail::BasicFullBelowCache::getGeneration | ( | void | ) | const |
generation determines whether cached entry is valid
Definition at line 122 of file FullBelowCache.h.
void ripple::detail::BasicFullBelowCache::clear | ( | ) |
Definition at line 128 of file FullBelowCache.h.
void ripple::detail::BasicFullBelowCache::reset | ( | ) |
Definition at line 135 of file FullBelowCache.h.
|
private |
Definition at line 142 of file FullBelowCache.h.
|
private |
Definition at line 143 of file FullBelowCache.h.