function cachedEntityTable
cachedEntityTable<
Row,
Input,
Cached = Row,
>
(
name: string,
table: Table<Row, Input>,
config: KeyedCacheConfig<Cached>,
dependsOn?: readonly DependsOnEntry[],
): { cache: KeyedCache<Cached>; table: Table<Row, Input>; }

Wire a keyed cache to an id-table in one step: build the cache, register it for the debug-footer stats, and register it with the table→cache invalidation registry so any write to the table (or to a dependsOn table whose triggers feed it — e.g. listings depend on listing_attendees) clears the cache automatically at the db-client layer. Centralises the create-cache + register trio that listings and groups would otherwise each repeat. Cached lets the cache hold a richer row than the table writes (e.g. listings cached with attendee counts).

dependsOn entries may carry whenColumns to narrow the listing_attendeeslistings dependency: the cache is only cleared on UPDATEs that touch one of those columns. INSERT / DELETE always clear.

Type Parameters

Row
Input
Cached = Row

Parameters

name: string
table: Table<Row, Input>
config: KeyedCacheConfig<Cached>
optional
dependsOn: readonly DependsOnEntry[]

Return Type

{ cache: KeyedCache<Cached>; table: Table<Row, Input>; }

Usage

import { cachedEntityTable } from "doc.ts";