Cachemere
Modular Caching Library for C++
|
1 #ifndef CACHEMERE_CONSTRAINT_COUNT_H
2 #define CACHEMERE_CONSTRAINT_COUNT_H
4 #include "cachemere/item.h"
6 namespace cachemere::policy {
62 [[nodiscard]]
size_t count()
const;
69 size_t m_maximum_count;
75 #include "constraint_count.hpp"
Count constraint.
Definition: constraint_count.h:13
size_t count() const
Get the number of items currently in the cache.
Definition: constraint_count.hpp:48
void clear()
Clears the policy.
Definition: constraint_count.hpp:8
A wrapper for items stored in the cache.
Definition: item.h:10
bool is_satisfied()
Returns whether the constraint is satisfied.
Definition: constraint_count.hpp:27
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_count.hpp:19
void on_evict(const Key &key, const CacheItem &item)
Eviction event handler.
Definition: constraint_count.hpp:42
size_t maximum_count() const
Get the maximum number of items allowed in cache.
Definition: constraint_count.hpp:53
void on_insert(const Key &key, const CacheItem &item)
Insertion event handler.
Definition: constraint_count.hpp:37
void update(size_t maximum_count)
Update the cache constraint.
Definition: constraint_count.hpp:32
bool can_add(const Key &key, const CacheItem &item)
Determines whether an insertion candidate can be added into the cache.
Definition: constraint_count.hpp:13