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 samecomponent.subcomponentdotted formcomponent_includealready uses, e.g.cached_by: refdata.client, for a consumer whose cache doesn't land in its defaultcoresubcomponent (every existing consumer iscore-shaped; a thin, DB-free*.clientconsumer is not). Resolved byresolve_output_pathinto 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 ascache_component/cache_component_upper/cache_subcomponent/cache_subcomponent_upper. There is no separatecache_subcomponentmodel flag – both are purely derived from splittingcached_byon its (optional) dot. Requiresread_for_cache; validated byvalidate_cached_byincore.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
- Codegen template library — the groups overview.
- ores.cpp.protocol.protocol_header — generates the
read_for_cacheRPC this facet's cache warms/reloads from.