Caches
NamiDB ships three process-wide caches that share data across
snapshots. All are Arc-shared and byte-budgeted.
| Cache | What it holds | RFC | Env var |
|---|---|---|---|
| AdjacencyCache | CSR adjacency arrays per edge SST | RFC-018 | NAMIDB_ADJACENCY |
| NodeViewCache | Decoded NodeView (id → label, props) lookups | RFC-019 | NAMIDB_NODE_CACHE |
| SstCache | Decoded SST body + edge property streams + parsed EdgeSstReader | RFC-020 | NAMIDB_SST_CACHE |
All three default to ON. Set the env var to 0 or off to disable.
Why cross-snapshot
A long-running write workload produces a new manifest version on every commit. Without cross-snapshot caches, every snapshot transition would invalidate the entire cache and re-pay the decode cost.
NamiDB’s caches are keyed by the immutable SST id, not by the snapshot. As long as an SST is referenced by any live snapshot, its decoded artifacts stay in cache.
Sizing
The default budgets are tuned for a “comfortable laptop”: ~512 MiB per cache. For server workloads, bump them:
export NAMIDB_ADJACENCY_BUDGET_MB=4096export NAMIDB_NODE_CACHE_BUDGET_MB=2048export NAMIDB_SST_CACHE_BUDGET_MB=8192For embedded use, you may want them smaller — they’re all eviction-bounded.
Observability
The Python client exposes:
print(client.cache_stats())# {# "adjacency": {"hits": ..., "misses": ..., "bytes": ...},# "node_view": {...},# "sst": {...}# }Hook this into your dashboards to spot working-set vs budget mismatches.
Hybrid cache (optional)
NamiDB embeds foyer for an
optional memory + NVMe tier — keeps the hot working set in RAM and
spills warm pages to local NVMe. Useful when bucket round-trips are
slow (cross-region) or expensive (egress fees).