DBCacheclass

new DBCache<I, T>(provider: DBProvider<I, T>)
ParamType
providerDBProvider<I, T>
The database provider the cached stores fetch from. required
Return
DBCache<I, T>
Cache of CollectionCache objects for multiple collections.
PropertyType
.providerDBProvider<I, T>
The database provider the cached stores fetch from. required readonly
.memoryMemoryDBProvider<I, T>
Memory provider reused from the provider chain to seed stores synchronously, if available. readonly

Cache of CollectionCache objects for multiple collections.

  • Use get(collection) to retrieve or create the CollectionCache for a given collection,
    then getItem(id) / getQuery(query) on that to get a specific store.
  • If the provider chain contains a CacheDBProvider, its memory is reused so stores can seed synchronously.

Examples

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

Methods

Go

DBCache.get()method

Get (or create) the CollectionCache for the given collection.

get(collection: Collection<string, II, TT>): CollectionCache<II, TT>
get(collection: Collection<string, I, T>): CollectionCache<I, T>
Go

DBCache.getItem()method

Get (or create) an ItemStore for a collection/id in one hop.

getItem(collection: Collection<string, II, TT>, id: II): ItemStore<II, TT>
Go

DBCache.getQuery()method

Get (or create) a QueryStore for a collection/query in one hop.

getQuery(collection: Collection<string, II, TT>, query: Query<Item<II, TT>>): QueryStore<II, TT>
Go

DBCache.refreshItem()method

Refresh a specific item store for a collection.

refreshItem(collection: Collection<string, II, TT>, id: II, maxAge?: number): Promise<void>
Go

DBCache.refreshItems()method

Refresh every cached item store for a collection.

refreshItems(collection: Collection<string, II, TT>, maxAge?: number): Promise<void>
Go

DBCache.refreshQuery()method

Refresh a specific query store for a collection.

refreshQuery(collection: Collection<string, II, TT>, query: Query<Item<II, TT>>, maxAge?: number): Promise<void>
Go

DBCache.refreshQueries()method

Refresh every cached query store for a collection.

refreshQueries(collection: Collection<string, II, TT>, maxAge?: number): Promise<void>
Go

DBCache.refreshAll()method

Refresh every cached store (items and queries) for a collection.

refreshAll(collection: Collection<string, II, TT>, maxAge?: number): Promise<void>