tvmjs
    Preparing search index...

    Interface ArtifactCacheTemplate

    Common Interface for the artifact cache

    interface ArtifactCacheTemplate {
        addToCache(
            url: string,
            storetype?: string,
            signal?: AbortSignal,
        ): Promise<void>;
        deleteInCache(url: string): Promise<void>;
        fetchWithCache(
            url: string,
            storetype?: string,
            signal?: AbortSignal,
        ): Promise<any>;
        hasAllKeys(keys: string[]): Promise<boolean>;
    }

    Implemented by

    Index

    Methods

    • Fetch data from url and add into cache. If already exists in cache, should return instantly.

      Parameters

      • url: string

        The url to the data to be cached. *

      • Optionalstoretype: string

        Only applies to ArtifactIndexedDBCache. Since indexedDB stores the actual *

      • Optionalsignal: AbortSignal

        An optional AbortSignal to abort data retrival. data rather than a request, we specify storagetype. There are two options:

        1. "json": IndexedDB stores fetch(url).json()
        2. "arraybuffer": IndexedDB stores fetch(url).arrayBuffer()
        • Note: This is an async function.

      Returns Promise<void>

    • Delete url in cache if url exists

      • Note: This is an async function.

      Parameters

      • url: string

      Returns Promise<void>

    • Retrieve data object that corresponds to url from cache. If data object does not exist in cache, fetch the data and then add to cache.

      Parameters

      • url: string

        The url to the data to be cached. *

      • Optionalstoretype: string

        This field is required so that ArtifactIndexedDBCache can store the actual data object (see addToCache()), while ArtifactCache which uses the Cache API can return the actual data object rather than the request. There are two options:

        1. "json": returns equivalent to fetch(url).json()
        2. "arraybuffer": returns equivalent to fetch(url).arraybuffer()
      • Optionalsignal: AbortSignal

        An optional AbortSignal allowing user to abort the fetching before its completion.

      Returns Promise<any>

      The data object (i.e. users do not need to call .json() or .arraybuffer()).

      • Note: This is an async function.
    • check if cache has all keys in Cache

      • Note: This is an async function.

      Parameters

      • keys: string[]

      Returns Promise<boolean>