浏览该文件的文档.
20 #include <unordered_map>
29 template<
typename K,
typename V>
34 using iterator =
typename std::list<kv_pair>::iterator;
35 using const_iterator =
typename std::list<kv_pair>::const_iterator;
43 V *
insert(
const K &key,V &&value)
57 V *
insert(
const K &key,
const V &value)
97 return &it->second->second;
119 uint64_t
hits()
const
std::unordered_map< K, iterator > m_cacheItemMap
std::pair< K, V > kv_pair
typename std::list< kv_pair >::const_iterator const_iterator
typename std::list< kv_pair >::iterator iterator
V * insert(const K &key, V &&value)
Inserts value under key in the cache
size_t size() const
Returns the number of values stored in the cache.
size_t capacity() const
Returns the maximum number of values that can be stored in the cache.
uint64_t misses() const
Returns how many of the find() calls did not found a value in the cache.
Cache(size_t capacity)
creates a cache that can hold capacity elements
uint64_t hits() const
Returns how many of the find() calls did find a value in the cache.
void remove(const K &key)
Removes entry key from the cache.
V * find(const K &key)
Finds a value in the cache given the corresponding key.
std::list< kv_pair > m_cacheItemList
void clear()
Clears all values in the cache.