Caching
Use namespaced portable caches with typed serialization, tag invalidation, and explicit stampede-protection capabilities across Redis, Workers, and local runtimes.
Namespaced key-value caching · Tag invalidation
Use an application-supplied Workers KV binding for namespaced cache storage with explicitly eventual capabilities.
Visit Cloudflare Workers KV ↗Use namespaced portable caches with typed serialization, tag invalidation, and explicit stampede-protection capabilities across Redis, Workers, and local runtimes.
Namespaced key-value caching · Tag invalidation
@playstack/cache/cloudflare-kv implements the portable cache contract over a structural Workers KV binding. KV cannot provide an atomic distributed lock and propagates writes eventually, so the driver declares process-local stampede protection and eventual tag invalidation.
import { createCache } from '@playstack/cache'
import { CloudflareKvCacheStorage } from '@playstack/cache/cloudflare-kv'
const cache = createCache({
app: 'billing',
environment: 'production',
driver: new CloudflareKvCacheStorage(env.CACHE),
})Logical millisecond expiry travels with the stored value while KV's provider expiration handles physical cleanup. The exact binding remains exposed through the driver client.