Skip to content

Function: registerRelationCacheTargetsForModel()

ts
function registerRelationCacheTargetsForModel(model: LucidModel): void;

Registers a model's configured cacheable 1:1 relations as process-global cache TARGETS, independent of ever constructing a CachingPreloader for it.

The host application calls this at boot for every model that declares a relationsCache, so the write-through eviction gate (isRelationCacheTarget) is correct in EVERY process — including a "cold" worker (e.g. a rates-sync command) that only writes a target row (Currency) and never queries the declaring parent (PaymentIntentTicket). Without this, such a process would skip deleteByTag and leave stale entries in a shared L2 for other processes until the TTL elapsed.

Booting the model's relations + validating belongsTo key consistency happens here too, so a misconfiguration fails loud at boot rather than at first load.

Parameters

ParameterTypeDescription
modelLucidModelA model that may declare a relationsCache.

Returns

void