Fixed sized cache that can be used with different policy types (e.g. LRU, FIFO, LFU)
More...
|
| fixed_sized_cache (size_t max_size, const Policy< Key > policy=Policy< Key >{}, on_erase_cb on_erase=[](const Key &, const value_type &) {}) |
| Fixed sized cache constructor.
|
|
void | Put (const Key &key, const Value &value) noexcept |
| Put element into the cache.
|
|
std::pair< value_type, bool > | TryGet (const Key &key) const noexcept |
| Try to get an element by the given key from the cache.
|
|
value_type | Get (const Key &key) const |
| Get element from the cache if present.
|
|
bool | Cached (const Key &key) const noexcept |
| Check whether the given key is presented in the cache.
|
|
std::size_t | Size () const |
| Get number of elements in cache.
|
|
bool | Remove (const Key &key) |
|
template<typename Key, typename Value, template< typename > class Policy = NoCachePolicy, typename HashMap = std::unordered_map<Key, WrappedValue<Value>>>
class caches::fixed_sized_cache< Key, Value, Policy, HashMap >
Fixed sized cache that can be used with different policy types (e.g. LRU, FIFO, LFU)
- Template Parameters
-
Key | Type of a key (should be hashable) |
Value | Type of a value stored in the cache |
Policy | Type of a policy to be used with the cache |
HashMap | Type of a hashmap to use for cache operations. Should have std::unordered_map compatible interface |