6#include <userver/cache/impl/lru.hpp>
17template <
typename T,
typename U,
typename Hash = std::hash<T>,
18 typename Equal = std::equal_to<T>>
21 explicit LruMap(size_t max_size,
const Hash& hash = Hash(),
22 const Equal& equal = Equal())
23 : impl_(max_size, hash, equal) {}
25 LruMap(LruMap&& lru)
noexcept =
default;
26 LruMap(
const LruMap& lru) =
delete;
27 LruMap& operator=(LruMap&& lru)
noexcept =
default;
28 LruMap& operator=(
const LruMap& lru) =
delete;
32 bool Put(
const T& key, U value) {
return impl_.Put(key, std::move(value)); }
37 template <
typename... Args>
38 U*
Emplace(
const T& key, Args&&... args) {
39 return impl_.Emplace(key, std::forward<Args>(args)...);
43 void Erase(
const T& key) { impl_.Erase(key); }
48 U*
Get(
const T& key) {
return impl_.Get(key); }
52 U
GetOr(
const T& key,
const U& default_value) {
53 auto* ptr = impl_.Get(key);
65 return impl_.SetMaxSize(new_max_size);
69 void Clear() {
return impl_.Clear(); }
72 template <
typename Function>
74 impl_.VisitAll(std::forward<Function>(func));
78 template <
typename Function>
80 impl_.VisitAll(std::forward<Function>(func));
83 size_t GetSize()
const {
return impl_.GetSize(); }
85 std::size_t GetCapacity()
const {
return impl_.GetCapacity(); }
88 impl::LruBase<T, U, Hash, Equal> impl_;