Skip to content

@nhtio/lucid-resourceful/private/utils/cache_service_resolver

Resolves the cache service used for relation caching via a precedence chain (per-model relationsCacheService option → process-wide default → none) and exposes the package-level default registration setter.

Type Aliases

Type AliasDescription
CacheDurationA cache TTL/duration as understood by the underlying cache service.
CacheServiceLikeThe cache service the relation cache talks to.
RelationCacheEntryOptionsPer-relation (and model-level) cache entry options.
RelationsCacheServiceResolverResolver supplied by the host that returns the cache service for a model, or null to opt that model out of relation caching.

Functions

FunctionDescription
getDefaultRelationsCacheServiceReads the currently-registered default resolver (used internally and by the write-through eviction hook). Exposed for completeness; prefer resolveRelationsCacheService.
isRelationCacheTargetReports whether a model identity name is a registered relation-cache TARGET, i.e. some model caches a 1:1 relation pointing at this model.
registerRelationCacheTargetRegisters a related-model identity name as a relation-cache TARGET. Idempotent.
resetRelationCacheTargetsClears the registered relation-cache target set. Test-only hook: the set is module-scoped and accumulates across a process, which can mask regressions between tests. Hosts must NOT call this at runtime.
resolveRelationsCacheServiceResolves the cache service for a model via the precedence chain: per-model resolver → process-wide default → null (uncached).
setDefaultRelationsCacheServiceRegisters (or clears) the process-wide default relation cache resolver.