CollectionCacheclass

new CollectionCache<I, T>(collection: Collection<string, I, T>, provider: DBProvider<I>, memory?: MemoryDBProvider<I>)
ParamType
collectionCollection<string, I, T>
The collection to cache stores for. required
providerDBProvider<I>
The database provider the stores fetch from. required
memoryMemoryDBProvider<I>
Optional memory provider used to seed stores and drive realtime updates.
Return
CollectionCache<I, T>
Cache of ItemStore and QueryStore objects for a single collection.
PropertyType
.collectionCollection<string, I, T>
The collection these cached stores belong to. required readonly
.providerDBProvider<I>
The database provider the cached stores fetch from. required readonly
.memoryMemoryDBProvider<I>
Optional memory provider used to seed stores and drive realtime updates. readonly

Cache of ItemStore and QueryStore objects for a single collection.

Examples

const cache = new CollectionCache(collection, provider);
 const store = cache.getItem("abc");

Methods

Go

CollectionCache.getItem()method

Get (or create) the ItemStore for the given id.

getItem(id: I): ItemStore<I, T>
Go

CollectionCache.getQuery()method

Get (or create) the QueryStore for the given query.

getQuery(query: Query<Item<I, T>>): QueryStore<I, T>
Go

CollectionCache.refreshItem()method

Refresh a specific item store.

refreshItem(id: I, maxAge?: number): Promise<void>
Go

CollectionCache.refreshItems()method

Refresh every cached item store.

refreshItems(maxAge?: number): Promise<void>
Go

CollectionCache.refreshQuery()method

Refresh a specific query store.

refreshQuery(query: Query<Item<I, T>>, maxAge?: number): Promise<void>
Go

CollectionCache.refreshQueries()method

Refresh every cached query store.

refreshQueries(maxAge?: number): Promise<void>
Go

CollectionCache.refreshAll()method

Refresh every cached store (items and queries).

refreshAll(maxAge?: number): Promise<void>