Node view cache #28
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Proposal: Canonical Node View Cache for Realtime Enrichment
Context
This document proposes an optimization for realtime node-data enrichment.
The idea is to reduce repeated SQLite reads in hot live paths by introducing a canonical node-view projection and, optionally, a small in-memory cache behind it.
The main motivation is database usage and realtime-path efficiency. A secondary benefit is that snapshot and realtime paths can share the same view-building logic.
Problem Summary
Current shape:
This creates two different ways to build the same logical node view:
That split is not automatically wrong, but it makes enrichment behavior harder to centralize and can force extra point reads whenever realtime payloads need canonical node information.
Goal
Introduce a single canonical node-view path that can be used by:
Optional secondary goal:
Non-Goal
This is not a proposal to make an in-memory store the source of truth.
The database/repository must remain authoritative.
Option 1: Post-Write Read-Through Cache
Flow
Schema
Pros
Cons
Option 2: Canonical Projector with Immediate Cache Update
Flow
Schema
Pros
Cons
UpsertNodefield preservationOption 3: Patch Cache Directly from Partial Ingest Payloads
Flow
Pros
Cons
Recommendation
Do not implement this option.
Why This Matters in This Repo
Current repository behavior is not plain replacement:
That means "just patch the cache from the packet" is not equivalent to persisted state.
If cache is introduced, it should reflect canonical merged state, not raw ingest fragments.
Rough Performance Expectations
These are rough estimates only.
Assumptions:
If cache is used only for occasional display-name enrichment
If cache backs canonical live payload generation for
node.*,log.event, and similar eventsWhere the real value is
Consistency is an important design benefit, but the primary reason to do this work is performance and architectural simplification around realtime reads.
Recommended Rollout
Phase 1: Define Canonical Projection
Phase 2: Add Safe Cache
node_idPhase 3: Consider Immediate Cache Updates
Suggested Design Constraints
Open Questions
GetNodeDetails, or a smaller dedicated WS node view?internal/ingest,internal/domain, or a dedicated projection package?Recommendation Summary
Recommended direction:
Short version: