Skip to content

provider-disk-cache.ts#

View Markdown

Source

5 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.

5 symbols 3 functions 1 interfaces 1 modules 9 parameters 4 members 3 returns

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.

View source

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>

View source

Members

Properties
NameTypeDescription
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): string

View source

Parameters

  • key string

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>

View source

Parameters

  • cacheDir string | null
  • key string
  • ttl number
  • now number

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>

View source

Parameters

  • cacheDir string | null
  • key string
  • data T | null
  • cachedAt number

Returns

Promise<void>