provider-disk-cache.ts#
5 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
Reference#
moduleprovider-disk-cacheA cross-build cache for provider card metadata. Open Graph cards have had one of these since ogp.persistCache; the prov…
A cross-build cache for provider card metadata.
Open Graph cards have had one of these since ogp.persistCache; the provider fetchers had a process-local Map, so every clean build and every fresh CI worker re-fetched Qiita, Zenn, npm, crates.io, PyPI, Docker Hub, CodePen, JSFiddle, Observable, Vimeo, and Twitch.
The envelope, the atomic replace, and the corrupt-entry handling follow ogp/cache.ts deliberately: a second cache with different failure behaviour would be a second thing to reason about.
interfaceProviderCacheEntry<T>What one cache file holds. null data is a remembered miss.
What one cache file holds. null data is a remembered miss.
Signature
interface ProviderCacheEntry<T>Members
Properties
| Name | Type | Description |
|---|---|---|
cachedAt |
number |
|
data |
T | null |
|
key |
string |
|
v |
1 |
fnproviderCacheFileName(key: string): stringA file name for a cache key. Hashed rather than escaped: a key carries a provid…
A file name for a cache key.
Hashed rather than escaped: a key carries a provider URL, and URLs contain characters a path cannot, in combinations that differ per platform.
Signature
export function providerCacheFileName(key: string): stringParameters
-
keystring
Returns
string
fnreadProviderCache<T>(cacheDir: string | null, key: string, ttl: number, now: number): Promise<T | null | undefined>Reads a cached value. Returns undefined for "nothing usable here" and null for…
Reads a cached value.
Returns undefined for "nothing usable here" and null for "this was fetched before and there was nothing", which are different answers: the second is a remembered miss and must not trigger another request.
Signature
export async function readProviderCache<T>(cacheDir: string | null, key: string, ttl: number, now: number): Promise<T | null | undefined>Parameters
-
cacheDirstring | null -
keystring -
ttlnumber -
nownumber
Returns
Promise<T | null | undefined>
fnwriteProviderCache<T>(cacheDir: string | null, key: string, data: T | null, cachedAt: number): Promise<void>Writes a value, replacing any existing entry atomically.
Writes a value, replacing any existing entry atomically.
Signature
export async function writeProviderCache<T>(cacheDir: string | null, key: string, data: T | null, cachedAt: number): Promise<void>Parameters
-
cacheDirstring | null -
keystring -
dataT | null -
cachedAtnumber
Returns
Promise<void>