Skip to main content

Module graph_cache

Module graph_cache 

Source
Expand description

Resident adjacency of one relationship type, cached per snapshot.

A traversal reads each record’s adjacency rows with one range scan per record and direction. When traversals at one snapshot keep reading the same relationships, holding them in memory is cheaper: the graph a type resolves to is a function of the snapshot’s commit index, so it is kept under (key, commit index) and shared by every reader of that snapshot, like the owner-set cache. A commit moves readers to a new index; older graphs age out by LRU.

When to build is a rent-or-buy decision. Building reads every adjacency row of the tenant once (the rows are keyed by record, not by type). Traversals report the rows they read through storage for a key at a commit index (GraphCache::rent); once that reaches the cost of one build, the next traversal builds and keeps the graph. A read-mostly tenant pays at most twice the build; a tenant whose commits keep moving the snapshot never builds, because its rent restarts at every commit.

Charged to its own budget (graph-cache-bytes) under the managed limit; a graph that does not fit is simply not kept, and traversals read storage as before.

Structs§

GraphCache
The store’s per-snapshot adjacency cache.

Type Aliases§

Graph
A cached graph: opaque to storage (the query layer’s adjacency type).