Volume Cartographer 2.27.0
|
Abstract Base Class for Key-Value Caches. More...
#include <vc/core/types/Cache.hpp>
Public Types | |
using | Pointer = std::shared_ptr< Cache > |
Public Member Functions | |
virtual | ~Cache ()=default |
virtual void | setCapacity (std::size_t newCapacity)=0 |
Set the maximum number of elements in the cache. More... | |
virtual auto | capacity () const -> std::size_t=0 |
Get the maximum number of elements in the cache. More... | |
virtual auto | size () const -> std::size_t=0 |
Get the current number of elements in the cache. More... | |
virtual auto | get (const TKey &k) -> TValue=0 |
Get an item from the cache by key. More... | |
virtual auto | put (const TKey &k, const TValue &v) -> void=0 |
Put an item into the cache. More... | |
virtual auto | contains (const TKey &k) -> bool=0 |
Check if an item is already in the cache. More... | |
virtual void | onEvict (std::function< bool(TKey &, TValue &)> fn)=0 |
Callback function when items are evicted. More... | |
virtual void | resetOnEvict ()=0 |
Remove the validation callback function. More... | |
virtual auto | evict () -> void=0 |
Evict items following the cache policy. More... | |
virtual auto | purge () -> void=0 |
Evict all items ignoring cache policy. More... | |
Protected Member Functions | |
Cache ()=default | |
Cache (const std::size_t capacity) | |
Protected Attributes | |
std::size_t | capacity_ {200} |
std::function< bool(TKey &, TValue &)> | on_eject_ |
Abstract Base Class for Key-Value Caches.
TKey | Key type |
TValue | Value type |
using volcart::Cache< TKey, TValue >::Pointer = std::shared_ptr<Cache> |
|
virtualdefault |
Default destructor
|
protecteddefault |
Default constructor
|
inlineexplicitprotected |
|
pure virtual |
Get the maximum number of elements in the cache.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Check if an item is already in the cache.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Evict items following the cache policy.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Get an item from the cache by key.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Callback function when items are evicted.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Evict all items ignoring cache policy.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Put an item into the cache.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Remove the validation callback function.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Set the maximum number of elements in the cache.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
pure virtual |
Get the current number of elements in the cache.
Implemented in volcart::LRUCache< TKey, TValue, TMutex >.
|
protected |
|
protected |