MCPcopy Create free account
hub / github.com/apache/tvm / fetchWithCache

Method fetchWithCache

web/src/artifact_cache.ts:367–375  ·  view source on GitHub ↗

* fetch the corresponding url object in response or stored object format * @param url url * @param storetype the storage type for indexedDB * @param signal an optional abort signal to abort fetching * @returns response in json, arraybuffer or pure response format

(url: string, storetype?: string, signal?: AbortSignal)

Source from the content-addressed store, hash-verified

365 * @returns response in json, arraybuffer or pure response format
366 */
367 async fetchWithCache(url: string, storetype?: string, signal?: AbortSignal): Promise<any> {
368 await this.addToCache(url, storetype, signal);
369 const result = await this.cache.match(new Request(url));
370 if (result === undefined) {
371 // Already called `addToCache()`, should expect the request in cache.
372 throw Error("Cannot fetch " + url);
373 }
374 return await this.responseTostoretype(result, storetype);
375 }
376
377 async addToCache(url: string, storetype?: string, signal?: AbortSignal) {
378 const request = new Request(url, signal ? { signal } : undefined);

Callers

nothing calls this directly

Calls 3

addToCacheMethod · 0.95
responseTostoretypeMethod · 0.95
matchMethod · 0.45

Tested by

no test coverage detected