#include <userver/cache/lru_set.hpp>
LRU set, thread safety matches Standard Library thread safety
Definition at line 17 of file lru_set.hpp.
Public Member Functions | |
LruSet (size_t max_size, const Hash &hash=Hash(), const Equal &equal=Equal()) | |
LruSet (LruSet &&lru) noexcept=default | |
LruSet (const LruSet &lru)=delete | |
LruSet & | operator= (LruSet &&lru) noexcept=default |
LruSet & | operator= (const LruSet &lru)=delete |
bool | Put (const T &key) |
void | Erase (const T &key) |
Removes key from LRU. | |
bool | Has (const T &key) |
Checks whether the key in LRU and updates its usage. | |
void | SetMaxSize (size_t new_max_size) |
Sets the max size of the LRU, truncates values if new_max_size < GetSize() | |
void | Invalidate () |
Removes all the elements. | |
template<typename Function > | |
void | VisitAll (Function &&func) const |
Call Function(const T&) for all items. | |
size_t | GetSize () const |
const T * | GetLeastUsed () |
|
inlineexplicit |
Definition at line 19 of file lru_set.hpp.
|
inline |
Removes key from LRU.
Definition at line 33 of file lru_set.hpp.
|
inline |
Returns pointer to the least recently used element or nullptr if LruSet is empty.
Definition at line 58 of file lru_set.hpp.
|
inline |
Definition at line 53 of file lru_set.hpp.
|
inline |
Checks whether the key in LRU and updates its usage.
Definition at line 36 of file lru_set.hpp.
|
inline |
Removes all the elements.
Definition at line 44 of file lru_set.hpp.
|
inline |
Adds key to the LRU or updates its usage
Definition at line 30 of file lru_set.hpp.
|
inline |
Sets the max size of the LRU, truncates values if new_max_size < GetSize()
Definition at line 39 of file lru_set.hpp.
|
inline |
Call Function(const T&) for all items.
Definition at line 48 of file lru_set.hpp.