|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
Per-node result cache. More...
#include <node_cache.h>
Public Member Functions | |
| void | clear () |
| Drop all cached entries (per-node enable/disable state preserved). | |
| std::size_t | hit_count () const |
| Lifetime hit count (incremented on lookup that returns a value). | |
| bool | is_enabled (const std::string &node_name) const |
True iff set_enabled(node_name, true) was the last call for it. | |
| std::optional< NodeResult > | lookup (const std::string &node_name, const std::string &state_hash) const |
| Lookup. nullopt if no cached result for this (node, state_hash). | |
| std::size_t | miss_count () const |
| Lifetime miss count (incremented on lookup that returns nullopt for an enabled node). | |
| void | set_enabled (const std::string &node_name, bool enabled) |
| Enable / disable caching for a specific node. | |
| std::size_t | size () const |
| Number of entries currently held. | |
| void | store (const std::string &node_name, const std::string &state_hash, NodeResult result) |
| Store the NodeResult for this (node, state_hash). | |
Per-node result cache.
Opt-in per node — callers must explicitly enable caching via set_enabled(name, true) so semantics never silently change for non-deterministic nodes.
Cache key = node_name + ":" + hash(state.serialize()). Cache values are full NodeResults (writes + Command + Sends), so a cached hit replays the original outcome without re-running the node. Hit / miss counters are exposed for tests + observability.
Only safe for pure nodes — deterministic, no external side effects, no time-dependent behavior. Streaming nodes are skipped because cached hits cannot replay token events.
Thread-safe: protected by an internal mutex. Callers should remember that fan-out branches see the same cache instance, so the first parallel branch to compute a (node, state) pair populates the entry the rest hit.
Definition at line 38 of file node_cache.h.