template <typename Key, typename Value>

class MarkAndSweepCache

Defined at line 18 of file ../../src/developer/memory/metrics/mas_cache.h

MarkAndSweepCache implements a cache that uses a mark-and-sweep strategy

to prune entries. It supports O(1) lookup and insertion.

Thread safety: only safe to use from a single thread.

Public Methods

void MarkAndSweepCache<Key, Value> ()

Defined at line 32 of file ../../src/developer/memory/metrics/mas_cache.h

std::optional<Value> Find (const Key & key)

Returns the value associated with the key if it exists, and marks it as active.

Defined at line 35 of file ../../src/developer/memory/metrics/mas_cache.h

bool Emplace (Key key, Value value)

Inserts the value for the key if not present, and always marks the entry as active.

Defined at line 46 of file ../../src/developer/memory/metrics/mas_cache.h

bool Erase (const Key & key)

Removes the entry for the key if present.

Returns true if an entry was removed, false otherwise.

Defined at line 58 of file ../../src/developer/memory/metrics/mas_cache.h

void Sweep ()

Removes all entries that have not been marked active since the last sweep.

Defined at line 61 of file ../../src/developer/memory/metrics/mas_cache.h