Template Class CacheManager¶
Defined in File cache_manager.hpp
Nested Relationships¶
Nested Types¶
Class Documentation¶
-
template<typename TreeNode, bool force_hash_collisions>
class CacheManager¶ This class implements a cache manager useful for the cases when the number of times the cached objects will be accessed is known.
- Template Parameters:
TreeNode – The evaluation tree node type used as the cache key.
force_hash_collisions – If true, forces all hash values to 0 (for testing collision safety).
Public Functions
-
inline void reset() noexcept¶
Resets all cached data.
-
inline ResultPtr access(key_type const &key) noexcept¶
Access cached data.
- Parameters:
key – The key that identifies the cached data.
- Returns:
ResultPtr to Result
-
inline ResultPtr store(key_type const &key, ResultPtr data) noexcept¶
- Parameters:
key – The key to identify the cached data.
data – The data to be cached.
- Returns:
Pointer to the stored data. Implictly accesses the stored data, hence, decays the lifetime if the key accesses a decaying cache entry. Passing
keythat was not present during construction of this CacheManager object, stores nothing, but still returns a valid pointer todata.
-
inline bool exists(key_type const &key) const noexcept¶
Check if the key exists in the database: does not check if cache exists.
-
inline int life(key_type const &key) const noexcept¶
if the key exists in the database, return the current lifetime count of the cached data otherwise return -1
-
inline int max_life(key_type const &key) const noexcept¶
if the key exists in the database, return the maximum lifetime count of the cached data that implies the maximum number of accesses allowed for this key before the cache is released. This value was set by the c’tor.
-
inline size_t alive_count() const noexcept¶
- Returns:
The number of entries with life_count greater than zero.
-
inline size_t size_in_bytes() const noexcept¶
- Returns:
Returns the sum of
Result::size_in_bytesof alive entries.
Public Static Functions
-
static inline CacheManager empty() noexcept¶
Get an empty cache manager.
Friends
- friend struct access_by
-
template<typename T>
struct access_by¶