// calogKv.h -- calog key-value library: a process-wide, thread-safe data store. // // Registers natives so any script, on any engine, can stash and fetch values under a // string key in one shared store: // kvSet(key, value) store a DEEP COPY of value under key (replaces any existing) -> nil // kvGet(key) -> a deep copy of the stored value, or nil if the key is absent // kvHas(key) -> true if the key is present, else false // kvDelete(key) remove the key (no error if it is absent) -> nil // kvKeys() -> a list of the stored keys (each a string) // // The store holds DATA ONLY: kvSet rejects a function value (calogFnE) so no script // callable's lifecycle leaks into the shared store -- kv keeps only values copied by // value. Keys are binary-safe: they are compared by bytes + length, so embedded NULs are // honored. The registry is process-wide and reference-counted across runtimes. #ifndef CALOG_KV_H #define CALOG_KV_H #include "calog.h" // Register the kv natives on a runtime. Idempotent across runtimes (shared registry). int32_t calogKvRegister(CalogT *calog); // Free every stored key + value (once the last registered runtime unregisters). Like // calogExportShutdown, call this BEFORE calogDestroy. The static registry bookkeeping is // intentionally never freed -- the natives stay callable right up until calogDestroy tears // the broker down -- so a native call after shutdown is safe (it just sees an empty store). void calogKvShutdown(void); #endif