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.

1. Summary

Two templates generating a consumer-side entity-mirror cache: the cache class itself (a partitioned_cache instantiation whose warm-up pages the entity's canonical list read to its end and whose refresh follows the canonical entity events), and a registrar-wiring snippet doing the startup warm-up and event subscription. Unlike every other facet, output lands in the consumer's component tree, not the entity's own — see cached_by below.

2. The ores.cpp.nats-event-cache facet

Disabled by default (#+default: disabled): an entity opts in by setting 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.

3. 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 has_tenant_id, because the cache keeps one partition per tenant; 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>).

4. Archetypes

Archetype Description
ores.cpp.nats-event-cache.cache_header Consumer-side entity-mirror cache class: a partitioned_cache instantiation warmed by the entity's paged list read and reloaded by canonical events. nats-event-cache facet.
ores.cpp.nats-event-cache.registrar_wiring Startup warm-up + canonical event-subscription snippet for a consumer-side entity-mirror cache. nats-event-cache facet.

5. See also

Emacs 29.3 (Org mode 9.6.15)