ComputedCache

See source code
Table of contents

A computed cache that stores derived data for records. The cache automatically updates when underlying records change and cleans up when records are deleted.

interface ComputedCache<Data, R extends UnknownRecord> {}

Example

const expensiveCache = store.createComputedCache('expensive', (book: Book) =>
  performExpensiveCalculation(book)
)

const result = expensiveCache.get(bookId)

Methods

get

Get the cached data for a record by its ID.

Parameters

NameDescription

id

IdOf<R>

The ID of the record

Returns

Data | undefined

The cached data or undefined if the record doesn't exist


Prev
CollectionDiff
Next
CreateComputedCacheOpts