Skip to content

caches::ICachePolicy

Cache policy abstract base class. More...

#include <cache_policy.hpp>

Inherited by caches::FIFOCachePolicy< Key >, caches::LFUCachePolicy< Key >, caches::LRUCachePolicy< Key >, caches::NoCachePolicy< Key >

Public Functions

Name
virtual ~ICachePolicy() =default
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.
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.

Detailed Description

template <typename Key >
class caches::ICachePolicy;

Cache policy abstract base class.

Template Parameters:

  • Key Type of a key a policy works with

Public Functions Documentation

function ~ICachePolicy

virtual ~ICachePolicy() =default

function Insert

virtual void Insert(
    const Key & key
) =0

Handle element insertion in a cache.

Parameters:

  • key Key that should be used by the policy

Reimplemented by: caches::LFUCachePolicy::Insert, caches::FIFOCachePolicy::Insert, caches::LRUCachePolicy::Insert, caches::NoCachePolicy::Insert

function Touch

virtual void Touch(
    const Key & key
) =0

Handle request to the key-element in a cache.

Parameters:

  • key

Reimplemented by: caches::FIFOCachePolicy::Touch, caches::NoCachePolicy::Touch, caches::LFUCachePolicy::Touch, caches::LRUCachePolicy::Touch

function Erase

virtual void Erase(
    const Key & key
) =0

Handle element deletion from a cache.

Parameters:

  • key Key that should be used by the policy

Reimplemented by: caches::LRUCachePolicy::Erase, caches::FIFOCachePolicy::Erase, caches::LFUCachePolicy::Erase, caches::NoCachePolicy::Erase

function ReplCandidate

virtual const Key & ReplCandidate() const =0

Return a key of a replacement candidate.

Return: Replacement candidate according to selected policy

Reimplemented by: caches::FIFOCachePolicy::ReplCandidate, caches::LFUCachePolicy::ReplCandidate, caches::LRUCachePolicy::ReplCandidate, caches::NoCachePolicy::ReplCandidate