6#include <userver/cache/impl/lru.hpp>
17template <
typename T,
typename U,
typename Hash = std::hash<T>,
typename Equal = std::equal_to<T>>
20 explicit LruMap(size_t max_size,
const Hash& hash = Hash(),
const Equal& equal = Equal())
21 : impl_(max_size, hash, equal) {}
23 LruMap(LruMap&& lru)
noexcept =
default;
24 LruMap(
const LruMap& lru) =
delete;
25 LruMap& operator=(LruMap&& lru)
noexcept =
default;
26 LruMap& operator=(
const LruMap& lru) =
delete;
30 bool Put(
const T& key, U value) {
return impl_.Put(key, std::move(value)); }
35 template <
typename... Args>
36 U*
Emplace(
const T& key, Args&&... args) {
37 return impl_.Emplace(key, std::forward<Args>(args)...);
41 void Erase(
const T& key) { impl_.Erase(key); }
46 U*
Get(
const T& key) {
return impl_.Get(key); }
50 U
GetOr(
const T& key,
const U& default_value) {
51 auto* ptr = impl_.Get(key);
62 void SetMaxSize(size_t new_max_size) {
return impl_.SetMaxSize(new_max_size); }
65 void Clear() {
return impl_.Clear(); }
68 template <
typename Function>
70 impl_.VisitAll(std::forward<Function>(func));
74 template <
typename Function>
76 impl_.VisitAll(std::forward<Function>(func));
79 size_t GetSize()
const {
return impl_.GetSize(); }
81 std::size_t GetCapacity()
const {
return impl_.GetCapacity(); }
84 impl::LruBase<T, U, Hash, Equal> impl_;