rippled
Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
ripple::detail::BasicFullBelowCache< Key > Class Template Reference

Remembers which tree keys have all descendants resident. More...

Collaboration diagram for ripple::detail::BasicFullBelowCache< Key >:
Collaboration graph
[legend]

Public Types

enum  { defaultCacheTargetSize = 0 }
 
using key_type = Key
 
using size_type = typename CacheType::size_type
 
using clock_type = typename CacheType::clock_type
 

Public Member Functions

 BasicFullBelowCache (std::string const &name, clock_type &clock, 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_typeclock ()
 Return the clock associated with the cache. More...
 
size_type 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< Key >
 

Private Attributes

KeyCache< Key > m_cache
 
std::atomic< std::uint32_tm_gen
 

Detailed Description

template<class Key>
class ripple::detail::BasicFullBelowCache< Key >

Remembers which tree keys have all descendants resident.

This optimizes the process of acquiring a complete tree.

Definition at line 37 of file FullBelowCache.h.

Member Typedef Documentation

◆ CacheType

template<class Key >
using ripple::detail::BasicFullBelowCache< Key >::CacheType = KeyCache<Key>
private

Definition at line 40 of file FullBelowCache.h.

◆ key_type

template<class Key >
using ripple::detail::BasicFullBelowCache< Key >::key_type = Key

Definition at line 45 of file FullBelowCache.h.

◆ size_type

template<class Key >
using ripple::detail::BasicFullBelowCache< Key >::size_type = typename CacheType::size_type

Definition at line 46 of file FullBelowCache.h.

◆ clock_type

template<class Key >
using ripple::detail::BasicFullBelowCache< Key >::clock_type = typename CacheType::clock_type

Definition at line 47 of file FullBelowCache.h.

Member Enumeration Documentation

◆ anonymous enum

template<class Key >
anonymous enum
Enumerator
defaultCacheTargetSize 

Definition at line 43 of file FullBelowCache.h.

Constructor & Destructor Documentation

◆ BasicFullBelowCache()

Construct the cache.

Parameters
nameA label for diagnostics and stats reporting.
collectorThe collector to use for reporting stats.
targetSizeThe cache target size.
targetExpirationSecondsThe expiration time for items.

Definition at line 56 of file FullBelowCache.h.

Member Function Documentation

◆ clock()

template<class Key >
clock_type& ripple::detail::BasicFullBelowCache< Key >::clock ( )

Return the clock associated with the cache.

Definition at line 69 of file FullBelowCache.h.

◆ size()

template<class Key >
size_type ripple::detail::BasicFullBelowCache< Key >::size ( ) const

Return the number of elements in the cache.

Thread safety: Safe to call from any thread.

Definition at line 79 of file FullBelowCache.h.

◆ sweep()

template<class Key >
void ripple::detail::BasicFullBelowCache< Key >::sweep ( )

Remove expired cache items.

Thread safety: Safe to call from any thread.

Definition at line 89 of file FullBelowCache.h.

◆ touch_if_exists()

template<class Key >
bool ripple::detail::BasicFullBelowCache< Key >::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.

Parameters
keyThe key to refresh.
Returns
true If the key exists.

Definition at line 101 of file FullBelowCache.h.

◆ insert()

template<class Key >
void ripple::detail::BasicFullBelowCache< Key >::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.

Parameters
keyThe key to insert.

Definition at line 114 of file FullBelowCache.h.

◆ getGeneration()

template<class Key >
std::uint32_t ripple::detail::BasicFullBelowCache< Key >::getGeneration ( void  ) const

generation determines whether cached entry is valid

Definition at line 121 of file FullBelowCache.h.

◆ clear()

template<class Key >
void ripple::detail::BasicFullBelowCache< Key >::clear ( )

Definition at line 127 of file FullBelowCache.h.

◆ reset()

template<class Key >
void ripple::detail::BasicFullBelowCache< Key >::reset ( )

Definition at line 134 of file FullBelowCache.h.

Member Data Documentation

◆ m_cache

template<class Key >
KeyCache<Key> ripple::detail::BasicFullBelowCache< Key >::m_cache
private

Definition at line 141 of file FullBelowCache.h.

◆ m_gen

template<class Key >
std::atomic<std::uint32_t> ripple::detail::BasicFullBelowCache< Key >::m_gen
private

Definition at line 142 of file FullBelowCache.h.