pub struct DispatchCache { /* private fields */ }Expand description
Host-owned dispatch cache. Construct once, share via Arc<DispatchCache>
across all CmfPluginInvoker::for_request calls so plans built for
one request can be reused by the next.
Cache key is the APL route_key. Entries pair with the cpex-core
snapshot generation observed at build time; a mismatch on lookup
triggers eviction and rebuild. v0 keys on route_key only —
entity-aware caching (entity_type/entity_name from MetaExtension)
is a follow-up when per-tenant lineup variation lands.
Implementations§
Source§impl DispatchCache
impl DispatchCache
pub fn new() -> Self
Sourcepub async fn get_or_build(
&self,
route: &CompiledRoute,
registry: &PluginRegistry,
manager: &PluginManager,
) -> Arc<RouteDispatchPlan>
pub async fn get_or_build( &self, route: &CompiledRoute, registry: &PluginRegistry, manager: &PluginManager, ) -> Arc<RouteDispatchPlan>
Get-or-build a plan for the route. Read-locked fast path returns the cached plan when the generation matches; otherwise drop the read lock, rebuild, and write-lock-insert. The brief window between read-miss and write-insert may let two concurrent builders race — both produce identical plans and the second insert just overwrites the first. Cheap relative to the cost of the build itself, and avoids holding a write lock across the build call.
Async because RouteDispatchPlan::build may invoke
PluginManager::build_override_entries, which calls plugin
factories and initialize() for routes that declare config:
overrides. Routes with no overrides take a synchronous path
inside the manager (no .await does any real work), so the
async cost is zero for the common case.