28 std::pair<iterator,bool> p=
il.push_front(infos);
31 il.relocate(
il.begin(),p.first);
45 auto it =
il.get<1>().find(token);
46 if(it!=
il.get<1>().end())
57 return cache.
insert({token, type, std::vector<pg_uuid_t>(children, children+nb_children)});
65 auto nb_children = opt.value().children.size();
67 for(
unsigned i=0; i<nb_children; ++i)
68 (*children)[i] = opt.value().children[i];
80 return opt.value().type;
gate_type circuit_cache_get_type(pg_uuid_t token)
Retrieve the type of a cached gate.
unsigned circuit_cache_get_children(pg_uuid_t token, pg_uuid_t **children)
Retrieve the children of a cached gate.
constexpr unsigned MAX_CIRCUIT_CACHE_SIZE
Maximum total byte size of the in-process circuit gate cache (1 MiB).
bool circuit_cache_create_gate(pg_uuid_t token, gate_type type, unsigned nb_children, pg_uuid_t *children)
Insert a new gate into the circuit cache.
static CircuitCache cache
Process-local singleton circuit gate cache.
LRU in-process cache for recently created provenance circuit gates.
C-linkage interface to the in-process provenance circuit cache.
Bounded LRU cache mapping gate UUIDs to their CircuitCacheInfos.
item_list il
The container holding cached entries.
unsigned current_size
Current total byte usage of cached entries.
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.
gate_type
Possible gate type in the provenance circuit.
@ gate_invalid
Invalid gate type.
All information stored for a single gate in the circuit cache.
unsigned size() const
Estimated memory footprint of this entry in bytes.