ores.cpp.nats-event-cache

Table of Contents

This page is the node for the ores.cpp.nats-event-cache facet of the codegen template library, part of the ores.cpp technical space. Each archetype below is documented, and holds its mustache source, in its own linked page — this page is the facet-level summary and the routing table to them.

Summary

Two templates generating a consumer-side entity-mirror cache: the cache class itself (a partitioned_cache instantiation warmed and reloaded via the entity's read_for_cache RPC), and a registrar-wiring snippet doing the startup warm-up and change-event subscription. Unlike every other facet, output lands in the consumer's component tree, not the entity's own — see cached_by below.

The ores.cpp.nats-event-cache facet

Disabled by default (#+default: disabled): an entity opts in by setting both read_for_cache: true (the RPC the cache warms/reloads from) and cached_by: <component> (the component that consumes the cache — e.g. party is defined in ores.refdata but sets cached_by: iam because IAM is the one that needs an in-process mirror of party data), then enabling the facet itself via :ores.cpp.nats-event-cache.enabled: true in its ** Flags drawer.

Mustache incantations

Model flags consumed by these templates:

  • cached_by (string, Flags) — the consumer component, e.g. cached_by: iam. Also accepts the same component.subcomponent dotted form component_include already uses, e.g. cached_by: refdata.client, for a consumer whose cache doesn't land in its default core subcomponent (every existing consumer is core-shaped; a thin, DB-free *.client consumer is not). Resolved by resolve_output_path into the {cache_component} / {cache_component_dir} / {cache_subcomponent} output-path tokens (distinct from {component} / {subcomponent}, which stay the entity's own), and exposed to templates as cache_component / cache_component_upper / cache_subcomponent / cache_subcomponent_upper. There is no separate cache_subcomponent model flag – both are purely derived from splitting cached_by on its (optional) dot. Requires read_for_cache; validated by validate_cached_by in core.py.

The cache class picks a boost::hash<...> specialisation for its key type when the entity's primary key is a UUID ({{#primary_key.is_uuid}}), since std::hash has no UUID specialisation; text/other primary keys use the partitioned_cache default (std::hash<Key>).

Archetypes

Archetype Description
ores.cpp.nats-event-cache.cache_header Consumer-side {entity}_cache.hpp: a partitioned_cache instantiation with a load(tenant_id) method calling the entity's read_for_cache RPC.
ores.cpp.nats-event-cache.registrar_wiring Consumer-side {entity}_cache_registrar.hpp: a warm_and_subscribe_{entity}_cache() free function doing startup warm-up and change-event-driven reload, for a hand-written consumer registrar to call.

See also

Emacs 29.3 (Org mode 9.6.15)