cache.ts
4 documented symbols. Read the signatures first, then expand each item for parameters, return types, and examples.
4
symbols
3
functions
1
modules
9
parameters
3
returns
Reference
modulecacheContent-hash based caching for OG images. Uses SHA256 of (template source + props + options) to determine if a re-rende…
Content-hash based caching for OG images.
Uses SHA256 of (template source + props + options) to determine if a re-render is needed. Cache dir: .cache/og-images
fncomputeCacheKey(templateSource: string, props: Record<string, unknown>, width: number, height: number): stringComputes a cache key from template + props + options.
Computes a cache key from template + props + options.
Signature
export function computeCacheKey(templateSource: string, props: Record<string, unknown>, width: number, height: number): string
Parameters
-
templateSourcestring -
propsRecord<string, unknown> -
widthnumber -
heightnumber
Returns
string
fngetCached(cacheDir: string, key: string): Promise<Buffer | null>Checks if a cached PNG exists for the given key. Returns the cached file path i…
Checks if a cached PNG exists for the given key. Returns the cached file path if found, null otherwise.
Signature
export async function getCached(cacheDir: string, key: string): Promise<Buffer | null>
Parameters
-
cacheDirstring -
keystring
Returns
Promise<Buffer | null>
fnwriteCache(cacheDir: string, key: string, png: Buffer): Promise<void>Writes a PNG buffer to the cache.
Writes a PNG buffer to the cache.
Signature
export async function writeCache(cacheDir: string, key: string, png: Buffer): Promise<void>
Parameters
-
cacheDirstring -
keystring -
pngBuffer
Returns
Promise<void>