FunctionOptionaloptions: CacheOptions = {}Stage-3 decorator that memorizes expensive reads.
What it does
get path like a cached getter; the set path invalidates cached value.class IconRenderer {
#value = 0;
// Accessor: cached read; any write invalidates immediately
@cache({clearOnNextFrame: true}) accessor data = {
get: () => this.#value,
set: (v: number) => { this.#value = v; }
};
// Caches per argument list (e.g., same path ⇒ same result until invalidation)
@cache({timeout: 5_000}) async loadSvg(path: string): Promise<string> {
// ...expensive IO
return fetch(path).then(r => r.text());
}
}
Optional caching configuration to define when to clear it (on event, after timeout, on next frame, on callback, etc.).