API Reference
Cache
Reference for BlurKitCache and built-in cache helpers.
When to use
Section titled “When to use”Use cache integration when your job may encode the same source multiple times.
Example
Section titled “Example”import { createFilesystemCache, encode } from 'blurkit/node'
const cache = createFilesystemCache({ dir: './.cache/blurkit', ttlMs: 120_000,})
const result = await encode('./public/hero.jpg', { cache })Inputs / Options / Behavior
Section titled “Inputs / Options / Behavior”interface BlurKitCache { get(key: string): Promise<BlurResult | undefined> | BlurResult | undefined set(key: string, value: BlurResult): Promise<void> | void}Built-in helpers:
createMemoryCache({ max? })fromblurkit/nodeandblurkit/denocreateFilesystemCache({ dir, ttlMs? })fromblurkit/nodeandblurkit/denocreateCloudflareCache({ name?, ttlSeconds? })fromblurkit/cloudflare
Limits / Caveats
Section titled “Limits / Caveats”- Cache keys are content-aware: they include a digest of the resolved image bytes plus every output-affecting option, so a changed file, Blob, or remote URL produces a new entry instead of stale output.
- Memory cache is process-local and reset on restart.
- Filesystem cache is local-disk scoped.
- Cloudflare cache depends on Worker Cache API availability and scope.