ChemPal Documentation - v1.18.0
    Preparing search index...

    Module helpers/requestCache

    Functions - Helpers

    fetchWithTimeout

    Calls fetch with a timeout. The abort also covers reading the body, so a stalled response can't hang a caller; the rejection is a TimeoutError DOMException.

    withTtlCache

    Wraps an async function with a persistent, time-to-live cache backed by chrome.storage.local. The returned function checks the cache first and only invokes fn on a miss or when the cached entry has expired. Only defined results are cached, so a failed or empty lookup (undefined) is never negatively cached. Any storage error is swallowed and the call falls through to fn, so the wrapper can never break a caller that runs without chrome.storage.

    Interfaces - Helpers

    TtlCacheOptions

    Options controlling a withTtlCache wrapper.

    Variables - Helpers

    DEFAULT_CACHE_TTL_MS

    Default freshness window for a cached response, in ms (chemicalInfo.cacheTtlDays in config.json).