Skip to content
VibORM
Esc
navigateopen⌘Jpreview
On this page

Cache Drivers

Multiple cache backends with a unified driver interface

Available Drivers

Driver Best For Persistence Distributed
MemoryCache Development, single-instance No No
CloudflareKVCache Cloudflare Workers Yes Yes

Choosing a Driver

Development / Testing

Use MemoryCache for local development. It requires no external dependencies and provides instant cache operations.

import { MemoryCache } from "viborm/cache/memory";

const client = createClient({
  schema,
  driver,
  cache: new MemoryCache(),
});

Production - Cloudflare Workers

Use CloudflareKVCache when deploying to Cloudflare Workers. It provides distributed caching across Cloudflare’s edge network.

import { CloudflareKVCache } from "viborm/cache/cloudflare-kv";

const client = createClient({
  schema,
  driver,
  cache: new CloudflareKVCache(env.MY_KV_NAMESPACE),
});

Production - Other Environments

For other production environments (Node.js, Vercel, AWS Lambda), implement a custom driver using Redis, Upstash, or another distributed cache. See Custom Drivers.

Driver Interface

All cache drivers extend the abstract CacheDriver class and implement four methods: get, set, delete, and clear. See Custom Drivers for the full interface and reference implementations.

Was this page helpful?