Skip to content

LookupCache

LookupCache = Map<Grant, Promise<Record<string, unknown>>>

Defined in: packages/db/src/utils.ts:54

Per-request cache that holds the resolved with lookup map for each grant.

Keyed by grant object identity so two queries that consult the same grant within a single request reuse the same lookup promise (each underlying LookupFn runs at most once).

The cache’s lifetime is tied to the surrounding async context rather than to any specific Db instance: createDb() calls transparently run inside an AsyncLocalStorage scope, and nested operations resolve their lookups through the active scope’s cache. Tests (or anything sharing a single Db across logical requests) can scope an explicit cache via runWithLookupCache.