![]() |
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 71 of file CircuitCache.h.
|
private |
Boost multi-index container type for cache entries.
Definition at line 80 of file CircuitCache.h.
The value type stored in the cache.
Definition at line 86 of file CircuitCache.h.
| typedef item_list::iterator CircuitCache::iterator |
Iterator type for iterating over cache entries in FIFO order.
Definition at line 88 of file CircuitCache.h.
|
inline |
Construct an empty cache.
Definition at line 91 of file CircuitCache.h.
|
inline |
Iterator to the first cached entry (oldest).
Definition at line 121 of file CircuitCache.h.
|
inline |
Past-the-end iterator for the cache.
Definition at line 128 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 43 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 insert is a no-op and the function returns false. Otherwise the entry is added and, if the cache exceeds its size budget, the oldest entry is removed.
| infos | Gate information to cache. |
true if the entry was newly inserted, false if it was already present. Definition at line 26 of file CircuitCache.cpp.


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