cacheKey
cacheKey(
resourceOrEntity,conditions,tenantOrContext?):string
Defined in: packages/ddd-core/persistence/helpers/cache-key.helper.ts:89
Derives a deterministic, collision-safe cache key from a canonical structured
tuple [tenant, resource, normalizedFilter], versioned and hashed with SHA-256.
Guarantees:
- Deterministic ordering: object keys are sorted recursively.
- Type preservation: numbers, booleans, strings, and nulls produce distinct representations.
- Null retention: explicit
nullconditions are preserved, distinct from omitted/undefined keys. - Fail-safe boundaries: non-serializable types and cyclic structures are rejected.
- Versioned namespace: keys are namespaced as
${tenant}:${resource}:v1:${hash}.
Parameters
Section titled “Parameters”resourceOrEntity
Section titled “resourceOrEntity”Logical resource name or object exposing aggregateName.
conditions
Section titled “conditions”Record<string, unknown>
Filter values that identify the cached record/query.
tenantOrContext?
Section titled “tenantOrContext?”An explicit tenant id, or an object carrying tenantId (such
as a request or job context). When omitted, the tenant of the registered
setTenantResolver resolver is used. See CacheKeyTenantSource.
Returns
Section titled “Returns”string
A versioned, hashed deterministic cache key.
Throws
Section titled “Throws”When tenant identity cannot be resolved.
Throws
Section titled “Throws”When conditions contain non-serializable values.