Your opinion will help to improve our service
Leave a feedback >#include <userver/cache/lru_map.hpp>
LRU key value storage (LRU cache), thread safety matches Standard Library thread safety
Definition at line 18 of file lru_map.hpp.
Public Member Functions | |
LruMap (size_t max_size, const Hash &hash=Hash(), const Equal &equal=Equal()) | |
LruMap (LruMap &&lru) noexcept=default | |
LruMap (const LruMap &lru)=delete | |
LruMap & | operator= (LruMap &&lru) noexcept=default |
LruMap & | operator= (const LruMap &lru)=delete |
bool | Put (const T &key, U value) |
template<typename... Args> | |
U * | Emplace (const T &key, Args &&... args) |
void | Erase (const T &key) |
Removes key from LRU. | |
U * | Get (const T &key) |
U | GetOr (const T &key, const U &default_value) |
U * | GetLeastUsed () |
void | SetMaxSize (size_t new_max_size) |
Sets the max size of the LRU, truncates values if new_max_size < GetSize() | |
void | Clear () |
Removes all the elements. | |
template<typename Function> | |
void | VisitAll (Function &&func) const |
Call Function(const T&, const U&) for all items. | |
template<typename Function> | |
void | VisitAll (Function &&func) |
Call Function(const T&, U&) for all items. | |
size_t | GetSize () const |
std::size_t | GetCapacity () const |
|
inlineexplicit |
Definition at line 20 of file lru_map.hpp.
|
inline |
Removes all the elements.
Definition at line 65 of file lru_map.hpp.
|
inline |
Returns pointer to value if the key is in LRU and updates its usage; constructs and adds a new key/value otherwise.
Definition at line 36 of file lru_map.hpp.
|
inline |
Removes key from LRU.
Definition at line 41 of file lru_map.hpp.
|
inline |
Returns pointer to value if the key is in LRU and updates its usage; returns nullptr otherwise.
Definition at line 46 of file lru_map.hpp.
|
inline |
Definition at line 81 of file lru_map.hpp.
|
inline |
Returns pointer to the least recently used value; returns nullptr if LRU is empty.
Definition at line 59 of file lru_map.hpp.
|
inline |
Returns value by key and updates its usage; returns default_value otherwise without modifying the cache.
Definition at line 50 of file lru_map.hpp.
|
inline |
Definition at line 79 of file lru_map.hpp.
|
inline |
Adds or rewrites key/value, updates its usage
Definition at line 30 of file lru_map.hpp.
|
inline |
Sets the max size of the LRU, truncates values if new_max_size < GetSize()
Definition at line 62 of file lru_map.hpp.
|
inline |
Call Function(const T&, U&) for all items.
Definition at line 75 of file lru_map.hpp.
|
inline |
Call Function(const T&, const U&) for all items.
Definition at line 69 of file lru_map.hpp.