|
rippled
|
Maintains a cache of keys with no associated data. More...

Classes | |
| struct | Entry |
| struct | Stats |
Public Types | |
| using | key_type = Key |
| using | clock_type = beast::abstract_clock< std::chrono::steady_clock > |
| using | size_type = typename map_type::size_type |
Public Member Functions | |
| KeyCache (std::string const &name, clock_type &clock, beast::insight::Collector::ptr const &collector, size_type target_size=0, std::chrono::seconds expiration=std::chrono::minutes{2}) | |
| Construct with the specified name. More... | |
| KeyCache (std::string const &name, clock_type &clock, size_type target_size=0, std::chrono::seconds expiration=std::chrono::minutes{2}) | |
| std::string const & | name () const |
| Retrieve the name of this object. More... | |
| clock_type & | clock () |
| Return the clock associated with the cache. More... | |
| size_type | size () const |
| Returns the number of items in the container. More... | |
| void | clear () |
| Empty the cache. More... | |
| void | reset () |
| void | setTargetSize (size_type s) |
| void | setTargetAge (std::chrono::seconds s) |
| template<class KeyComparable > | |
| bool | exists (KeyComparable const &key) const |
Returns true if the key was found. More... | |
| bool | insert (Key const &key) |
| Insert the specified key. More... | |
| template<class KeyComparable > | |
| bool | touch_if_exists (KeyComparable const &key) |
| Refresh the last access time on a key if present. More... | |
| bool | erase (key_type const &key) |
| Remove the specified cache entry. More... | |
| void | sweep () |
| Remove stale entries from the cache. More... | |
Private Types | |
| using | map_type = hardened_hash_map< key_type, Entry, Hash, KeyEqual > |
| using | iterator = typename map_type::iterator |
Private Member Functions | |
| void | collect_metrics () |
Private Attributes | |
| Mutex | m_mutex |
| map_type | m_map |
| Stats | m_stats |
| clock_type & | m_clock |
| const std::string | m_name |
| size_type | m_target_size |
| clock_type::duration | m_target_age |
Maintains a cache of keys with no associated data.
The cache has a target size and an expiration time. When cached items become older than the maximum age they are eligible for removal during a call to sweep.
Definition at line 43 of file KeyCache.h.
| using ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::key_type = Key |
Definition at line 46 of file KeyCache.h.
| using ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::clock_type = beast::abstract_clock<std::chrono::steady_clock> |
Definition at line 47 of file KeyCache.h.
|
private |
Definition at line 83 of file KeyCache.h.
|
private |
Definition at line 84 of file KeyCache.h.
| using ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::size_type = typename map_type::size_type |
Definition at line 87 of file KeyCache.h.
| ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::KeyCache | ( | std::string const & | name, |
| clock_type & | clock, | ||
| beast::insight::Collector::ptr const & | collector, | ||
| size_type | target_size = 0, |
||
| std::chrono::seconds | expiration = std::chrono::minutes{2} |
||
| ) |
Construct with the specified name.
| size | The initial target size. |
| age | The initial expiration time. |
Definition at line 104 of file KeyCache.h.
| ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::KeyCache | ( | std::string const & | name, |
| clock_type & | clock, | ||
| size_type | target_size = 0, |
||
| std::chrono::seconds | expiration = std::chrono::minutes{2} |
||
| ) |
Definition at line 119 of file KeyCache.h.
| std::string const& ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::name | ( | ) | const |
Retrieve the name of this object.
Definition at line 139 of file KeyCache.h.
| clock_type& ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::clock | ( | ) |
Return the clock associated with the cache.
Definition at line 146 of file KeyCache.h.
| size_type ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::size | ( | ) | const |
Returns the number of items in the container.
Definition at line 153 of file KeyCache.h.
| void ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::clear | ( | ) |
Empty the cache.
Definition at line 161 of file KeyCache.h.
| void ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::reset | ( | ) |
Definition at line 168 of file KeyCache.h.
| void ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::setTargetSize | ( | size_type | s | ) |
Definition at line 177 of file KeyCache.h.
| void ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::setTargetAge | ( | std::chrono::seconds | s | ) |
Definition at line 184 of file KeyCache.h.
| bool ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::exists | ( | KeyComparable const & | key | ) | const |
Returns true if the key was found.
Does not update the last access time.
Definition at line 195 of file KeyCache.h.
| bool ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::insert | ( | Key const & | key | ) |
Insert the specified key.
The last access time is refreshed in all cases.
true If the key was newly inserted. Definition at line 213 of file KeyCache.h.
| bool ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::touch_if_exists | ( | KeyComparable const & | key | ) |
Refresh the last access time on a key if present.
true If the key was found. Definition at line 234 of file KeyCache.h.
| bool ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::erase | ( | key_type const & | key | ) |
Remove the specified cache entry.
| key | The key to remove. |
false If the key was not found. Definition at line 253 of file KeyCache.h.
| void ripple::KeyCache< Key, Hash, KeyEqual, Mutex >::sweep | ( | ) |
Remove stale entries from the cache.
Definition at line 267 of file KeyCache.h.
|
private |
Definition at line 309 of file KeyCache.h.
|
mutableprivate |
Definition at line 90 of file KeyCache.h.
|
private |
Definition at line 91 of file KeyCache.h.
|
mutableprivate |
Definition at line 92 of file KeyCache.h.
|
private |
Definition at line 93 of file KeyCache.h.
|
private |
Definition at line 94 of file KeyCache.h.
|
private |
Definition at line 95 of file KeyCache.h.
|
private |
Definition at line 96 of file KeyCache.h.
1.8.17