15#include <unordered_map>
17namespace neograph::graph {
49 std::optional<NodeResult>
lookup(
const std::string& node_name,
50 const std::string& state_hash)
const;
53 void store(
const std::string& node_name,
54 const std::string& state_hash,
70 static std::string make_key(
const std::string& node_name,
71 const std::string& state_hash);
73 mutable std::mutex mu_;
74 std::set<std::string> enabled_nodes_;
75 std::unordered_map<std::string, NodeResult> entries_;
76 mutable std::size_t hits_ = 0;
77 mutable std::size_t misses_ = 0;
NEOGRAPH_API export/import macro for shared-library builds.
void store(const std::string &node_name, const std::string &state_hash, NodeResult result)
Store the NodeResult for this (node, state_hash).
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).
void set_enabled(const std::string &node_name, bool enabled)
Enable / disable caching for a specific node.
std::size_t miss_count() const
Lifetime miss count (incremented on lookup that returns nullopt for an enabled node).
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.
void clear()
Drop all cached entries (per-node enable/disable state preserved).
std::size_t size() const
Number of entries currently held.
Graph engine type definitions: channels, edges, nodes, events, and control flow.
NEOGRAPH_API std::string hash_state_for_cache(const json &state_value)
Stable hash over the JSON state used as the cache-key suffix.
Extended result returned by node execution.