CacheStore
The storage interface of the ISR cache.
The storage interface of the ISR cache. Every method may be asynchronous (a shared store is). A
set indexes the entry's tags, a delete removes the entry from every tag it was indexed under.
A store must never return an entry that was deleted, and must tolerate delete of a missing key.
Import#
ts
import type { CacheStore } from "@shadow-js/dusk/server";
Signature#
ts
interface CacheStore {
/** The entry stored under `key`, or `undefined`. */
get(key: string): Promise<CacheEntry | undefined>;
/** Stores `entry` under `key`, replacing any entry there, and indexes its tags. */
set(key: string, entry: CacheEntry): Promise<void>;
/** Removes the entry under `key` and its tag index entries. A missing key is not an error. */
delete(key: string): Promise<void>;
/** The keys indexed under `tag`, in no particular order. */
tags(tag: string): Promise<readonly string[]>;
/**
* Removes every entry indexed under `tag` and the tag's index, as one operation of the store. Optional: a
* store that has none is purged by the cache with `tags` and `delete`. A shared store implements it so that an
* entry written while the purge runs stays indexed (and so purgeable) and no index is lost.
*/
purgeTag?(tag: string): Promise<void>;
}
Members#
| Name | Type | Description |
|---|---|---|
get |
get(key: string): Promise<CacheEntry | undefined> |
The entry stored under key, or undefined. |
set |
set(key: string, entry: CacheEntry): Promise<void> |
Stores entry under key, replacing any entry there, and indexes its tags. |
delete |
delete(key: string): Promise<void> |
Removes the entry under key and its tag index entries. A missing key is not an error. |
tags |
tags(tag: string): Promise<readonly string[]> |
The keys indexed under tag, in no particular order. |
purgeTag? |
purgeTag?(tag: string): Promise<void> |
Removes every entry indexed under tag and the tag's index, as one operation of the store. Optional: a store that has none is purged by the cache with tags and delete. A shared store implements it so that an entry written while the purge runs stays indexed (and so purgeable) and no index is lost. |