Cachemere
Modular Caching Library for C++
|
1 #ifndef CACHEMERE_CONSTRAINT_MEMORY_H
2 #define CACHEMERE_CONSTRAINT_MEMORY_H
4 #include "cachemere/item.h"
6 namespace cachemere::policy {
48 void update(
size_t max_memory);
52 [[nodiscard]]
size_t memory()
const;
78 size_t m_maximum_memory;
84 #include "constraint_memory.hpp"
void clear()
Clears the policy.
Definition: constraint_memory.hpp:8
ConstraintMemory(size_t max_memory)
Constructor.
Definition: constraint_memory.hpp:3
void update(size_t max_memory)
Update the cache constraint.
Definition: constraint_memory.hpp:29
void on_update(const Key &key, const CacheItem &old_item, const CacheItem &new_item)
Update event handler.
Definition: constraint_memory.hpp:50
bool is_satisfied()
Returns whether the constraint is satisfied.
Definition: constraint_memory.hpp:24
A wrapper for items stored in the cache.
Definition: item.h:10
size_t memory() const
Get the amount of memory currently used by the cache.
Definition: constraint_memory.hpp:34
bool can_add(const Key &key, const CacheItem &item)
Determines whether an insertion candidate can be added into the cache.
Definition: constraint_memory.hpp:13
Memory constraint.
Definition: constraint_memory.h:13
size_t maximum_memory() const
Get the maximum amount of memory that can be used by the cache.
Definition: constraint_memory.hpp:39
void on_insert(const Key &key, const CacheItem &item)
Insertion event handler.
Definition: constraint_memory.hpp:44
bool can_replace(const Key &key, const CacheItem &old_item, const CacheItem &new_item)
Determines whether an item already in cache can be updated.
Definition: constraint_memory.hpp:18
void on_evict(const Key &key, const CacheItem &item)
Eviction event handler.
Definition: constraint_memory.hpp:57