data.cache.internal ≡
template <typename Key, typename LUtime, auto Associativity, auto Depth> class cache_tags §
Handles metadata related to entries in the cache, but does not store data.
Parameters
-
typename KeyThe type of key for looking up a value in the cache.
-
typename LUtimeThe type to use for storing the time a cache entry was most recently used. Using a wider type makes LRU eviction more accurate for a set associative cache, but for a direct cache where LRU does not apply, using
uint1saves space. -
auto AssociativityThe number of entries to store for a given hash value, keeping the most recently used values. Pass 1 to create a directly mapped cache.
-
auto DepthThe total number of entries to cache. Must be a multiple of
Associativity.
Aliases
-
using set_index_t = index_t<cache_tags::_setCount> §
-
using entry_index_t = uint<cache_tags::_entryIndexBits> §
Methods
-
void initialize() §
Initialize or re-initialize a cache object. Re-initializing the cache invalidates all entries. The caller must ensure that intialize is not called concurrently with
get. -
cache_tags_get_result<cache_tags::entry_index_t, Key> get(Key key, cache_tags::set_index_t set_index, bool mark_as_unwritten) §
Get the index of a value from the
cache_tags, if present.Arguments
-
Key keyThe key to lookup.
-
cache_tags::set_index_t set_index
The hashed value of the key.
-
bool mark_as_unwritten
Mark the cache entry as unwritten, meaning it hasn’t been written to the backing store yet.
-
-
optional<Key> get_and_clear_unwritten_key( cache_tags::set_index_t set_index, cache_tags::entry_index_t entry_index ) §
Returns the key at the given (set_index, entry_index) tuple as well as whether the value is unwritten. Marks the key as written. Must not be called concurrently with
get.Arguments
-
cache_tags::set_index_t set_index
Set index of the key to lookup.
-
cache_tags::entry_index_t entry_index
Way index of the key to lookup.
-