8 #include <unordered_map> 15 template <
typename Key,
typename Value,
typename Policy = NoCachePolicy<Key>>
20 using iterator =
typename std::unordered_map<Key, Value>::iterator;
23 typename std::unordered_map<Key, Value>::const_iterator;
29 const Policy& policy = Policy())
39 void Put(
const Key& key,
const Value& value)
51 Erase(disp_candidate_key);
70 const Value&
Get(
const Key& key)
const 77 throw std::range_error{
"No such element in the cache"};
81 return elem_it->second;
102 void Insert(
const Key& key,
const Value& value)
114 void Update(
const Key& key,
const Value& value)
void Put(const Key &key, const Value &value)
Definition: cache.hpp:39
bool Contains(const Key &key)
Definition: cache.hpp:63
typename std::unordered_map< Key, Value >::const_iterator const_iterator
Definition: cache.hpp:23
const_iterator FindElem(const Key &key) const
Definition: cache.hpp:120
std::unordered_map< Key, Value > cache_items_map
Definition: cache.hpp:128
void Erase(const Key &key)
Definition: cache.hpp:108
fixed_sized_cache(size_t max_size, const Policy &policy=Policy())
Definition: cache.hpp:27
typename std::unordered_map< Key, Value >::iterator iterator
Definition: cache.hpp:20
const size_t Size() const
Definition: cache.hpp:84
std::mutex safe_op
Definition: cache.hpp:131
Policy cache_policy
Definition: cache.hpp:130
void Clear()
Definition: cache.hpp:92
size_t max_cache_size
Definition: cache.hpp:133
void Update(const Key &key, const Value &value)
Definition: cache.hpp:114
void Insert(const Key &key, const Value &value)
Definition: cache.hpp:102
typename std::lock_guard< std::mutex > operation_guard
Definition: cache.hpp:25
const Value & Get(const Key &key) const
Definition: cache.hpp:70