![]() |
ProvSQL C/C++ API
Adding support for provenance and uncertainty management to PostgreSQL databases
|
Bounded LRU cache mapping gate UUIDs to their CircuitCacheInfos.
More...
#include "CircuitCache.h"
Public Types | |
| typedef CircuitCacheInfos | item_type |
| The value type stored in the cache. | |
| typedef item_list::iterator | iterator |
| Iterator type for iterating over cache entries in FIFO order. | |
Public Member Functions | |
| CircuitCache () | |
| Construct an empty cache. | |
| bool | insert (const CircuitCacheInfos &infos) |
| Insert a new gate into the cache, evicting the oldest if necessary. | |
| std::optional< CircuitCacheInfos > | get (pg_uuid_t token) const |
| Look up a gate by UUID. | |
| iterator | begin () |
| Iterator to the first cached entry (oldest). | |
| iterator | end () |
| Past-the-end iterator for the cache. | |
Private Types | |
| typedef multi_index_container< CircuitCacheInfos, indexed_by< sequenced<>, hashed_unique< member< CircuitCacheInfos, pg_uuid_t, &CircuitCacheInfos::token > > > > | item_list |
| Boost multi-index container type for cache entries. | |
Private Attributes | |
| item_list | il |
| The container holding cached entries. | |
| unsigned | current_size |
| Current total byte usage of cached entries. | |
Bounded LRU cache mapping gate UUIDs to their CircuitCacheInfos.
Internally a Boost multi_index_container provides two views of the same data:
token for O(1) lookup.The cache is not thread-safe; each backend process maintains its own instance.
Definition at line 75 of file CircuitCache.h.
|
private |
Boost multi-index container type for cache entries.
Definition at line 84 of file CircuitCache.h.
The value type stored in the cache.
Definition at line 90 of file CircuitCache.h.
| typedef item_list::iterator CircuitCache::iterator |
Iterator type for iterating over cache entries in FIFO order.
Definition at line 92 of file CircuitCache.h.
|
inline |
Construct an empty cache.
Definition at line 95 of file CircuitCache.h.
|
inline |
Iterator to the first cached entry (oldest).
Definition at line 128 of file CircuitCache.h.
|
inline |
Past-the-end iterator for the cache.
Definition at line 135 of file CircuitCache.h.
| std::optional< CircuitCacheInfos > CircuitCache::get | ( | pg_uuid_t | token | ) | const |
Look up a gate by UUID.
| token | UUID of the gate to find. |
std::optional containing the CircuitCacheInfos if found, or std::nullopt on a cache miss. Definition at line 62 of file CircuitCache.cpp.
| bool CircuitCache::insert | ( | const CircuitCacheInfos & | infos | ) |
Insert a new gate into the cache, evicting the oldest if necessary.
If infos.token is already present in the cache the existing entry is bumped to the LRU front and, when infos carries strictly more information than the existing entry (a real gate_type replacing a stored gate_invalid placeholder, or a non-empty children list replacing an empty one), its contents are overwritten in place. Otherwise the entry is added and, if the cache then exceeds its size budget, the oldest entry (FIFO tail) is removed.
| infos | Gate information to cache. |
true if the entry was newly inserted, false if it was already present (regardless of whether it was upgraded). Definition at line 26 of file CircuitCache.cpp.

|
private |
Current total byte usage of cached entries.
Definition at line 86 of file CircuitCache.h.
|
private |
The container holding cached entries.
Definition at line 85 of file CircuitCache.h.