5#ifndef CACHE_POLICY_HPP
6#define CACHE_POLICY_HPP
8#include <unordered_set>
17template <
typename Key>
27 virtual void Insert(
const Key &key) = 0;
33 virtual void Touch(
const Key &key) = 0;
38 virtual void Erase(
const Key &key) = 0;
55template <
typename Key>
64 key_storage.emplace(key);
67 void Touch(
const Key &key)
noexcept override
73 void Erase(
const Key &key)
noexcept override
75 key_storage.erase(key);
81 return *key_storage.cbegin();
85 std::unordered_set<Key> key_storage;
Cache policy abstract base class.
Definition: cache_policy.hpp:19
virtual void Erase(const Key &key)=0
Handle element deletion from a cache.
virtual const Key & ReplCandidate() const =0
Return a key of a replacement candidate.
virtual void Insert(const Key &key)=0
Handle element insertion in a cache.
virtual void Touch(const Key &key)=0
Handle request to the key-element in a cache.
Basic no caching policy class.
Definition: cache_policy.hpp:57
void Touch(const Key &key) noexcept override
Handle request to the key-element in a cache.
Definition: cache_policy.hpp:67
const Key & ReplCandidate() const noexcept override
Return a key of a replacement candidate.
Definition: cache_policy.hpp:79
void Insert(const Key &key) override
Handle element insertion in a cache.
Definition: cache_policy.hpp:62
void Erase(const Key &key) noexcept override
Handle element deletion from a cache.
Definition: cache_policy.hpp:73