libboxes
boxes is a set of specialised containers built on top of STL
Classes | Functions
cache.hpp File Reference

Implements generic cache with pluggable eviction policies. More...

#include "compiler.hpp"
#include <list>
#include <map>
#include <memory>
#include <unordered_map>
Include dependency graph for cache.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  boxes::cache::policy::NoEviction< K, V >
 Eviction policy that never evicts elements. More...
 
class  boxes::cache::policy::MRU< K, V >
 Constructs a new MRU eviction policy. More...
 
class  boxes::cache::policy::LFU< K, V >
 Eviction policy that evicts the least frequently used element. More...
 
class  boxes::cache::Cache< K, V, CachePolicy >
 Generic cache with pluggable eviction policies. More...
 

Functions

template<typename K , typename V >
Cache< K, V, policy::LRU > boxes::cache::makeLRU (std::size_t size)
 Create a new LRU cache. More...
 
template<typename K , typename V >
Cache< K, V, policy::MRU > boxes::cache::makeMRU (std::size_t size)
 Create a new MRU cache. More...
 
template<typename K , typename V >
Cache< K, V, policy::NoEviction > boxes::cache::makeNoEviction ()
 Create a new no eviction cache. More...
 
template<typename K , typename V >
Cache< K, V, policy::LFU > boxes::cache::makeLFU (std::size_t size)
 Create a new LFU cache. More...
 

Detailed Description

Implements generic cache with pluggable eviction policies.

Copyright 2024 Tomasz Wisniewski twdev.nosp@m..blo.nosp@m.gger@.nosp@m.gmai.nosp@m.l.com

Definition in file cache.hpp.

Function Documentation

◆ makeLFU()

template<typename K , typename V >
Cache< K, V, policy::LFU > boxes::cache::makeLFU ( std::size_t  size)

Create a new LFU cache.

Template Parameters
Kkey type (must be hashable, comparable and copyable)
Vvalue type
Parameters
sizemaximum number of elements the cache can hold
Returns
Cache<K, V, LFU>

Definition at line 654 of file cache.hpp.

◆ makeLRU()

template<typename K , typename V >
Cache< K, V, policy::LRU > boxes::cache::makeLRU ( std::size_t  size)

Create a new LRU cache.

Template Parameters
Kkey type (must be hashable, comparable and copyable)
V
Parameters
sizemaximum number of elements the cache can hold
Returns
Cache<K, V, LRU>

Definition at line 616 of file cache.hpp.

◆ makeMRU()

template<typename K , typename V >
Cache< K, V, policy::MRU > boxes::cache::makeMRU ( std::size_t  size)

Create a new MRU cache.

Template Parameters
Kkey type (must be hashable, comparable and copyable)
Vvalue type
Parameters
sizemaximum number of elements the cache can hold
Returns
Cache<K, V, MRU>

Definition at line 629 of file cache.hpp.

◆ makeNoEviction()

template<typename K , typename V >
Cache< K, V, policy::NoEviction > boxes::cache::makeNoEviction ( )

Create a new no eviction cache.

Template Parameters
Kkey type (must be hashable, comparable and copyable)
Vvalue type
Returns
Cache<K, V, NoEviction>

Definition at line 641 of file cache.hpp.