|
quic/qbox
|
RegionLRUCache - A true LRU cache for region-based address lookups. More...
#include <addrmap_cache_examples.h>


Public Member Functions | |
| bool | get (const Key &key, Value &value) override |
| Retrieve value from cache and update LRU order. | |
| void | put (const Key &key, const Value &value, uint64_t size) override |
| Insert or update region in cache with LRU eviction. | |
| void | clear () override |
| Clear all cached entries. | |
| uint64_t | get_hits () const override |
| uint64_t | get_misses () const override |
| void | reset_stats () override |
RegionLRUCache - A true LRU cache for region-based address lookups.
This cache implements proper Least Recently Used (LRU) eviction policy using a std::list-based approach. When a region is accessed, it's moved to the back of the list (most recently used position). When eviction is needed, the front entry (least recently used) is removed.
Key features:
Use this cache when workloads exhibit temporal locality in region access patterns.
Note: SystemC uses cooperative multitasking (single OS thread), so thread-local storage is not needed. Each router instance maintains its own cache.
|
inlineoverridevirtual |
Clear all cached entries.
Implements gs::AddrMapCacheBase< Key, Value >.
|
inlineoverridevirtual |
Retrieve value from cache and update LRU order.
Searches through the vector from back to front (most recently used first) for better cache hit performance. If found, moves the entry to the back (most recently used) and returns true.
| key | Address to look up |
| value | Output parameter for the cached target info |
Implements gs::AddrMapCacheBase< Key, Value >.
|
inlineoverridevirtual |
Implements gs::AddrMapCacheBase< Key, Value >.
|
inlineoverridevirtual |
Implements gs::AddrMapCacheBase< Key, Value >.
|
inlineoverridevirtual |
Insert or update region in cache with LRU eviction.
If a region with the same start address already exists, updates it and moves to back. If new and at capacity, evicts the least recently used entry (front of vector) before inserting at back.
| key | Region start address |
| value | Target info to cache |
| size | Region size |
Implements gs::AddrMapCacheBase< Key, Value >.
|
inlineoverridevirtual |
Implements gs::AddrMapCacheBase< Key, Value >.