Packages@g14o/cache
Overview
Framework-agnostic caching with pluggable stores and in-memory dev/build fallbacks.
Framework-agnostic caching with pluggable stores (memory, Upstash, node-redis/ioredis). In-memory fallbacks apply automatically in development, test, and static build phases.
Install
pnpm add @g14o/cache @upstash/redisInstall only the peer matching your store backend.
Quick start
import { createCache } from "@g14o/cache";
import { upstashStore } from "@g14o/cache/upstash";
import { logger } from "@/lib/logger";
import { env } from "@/lib/env";
export const { withCache, invalidateCache, invalidateCacheKey } = createCache({
store: upstashStore({
url: env.UPSTASH_REDIS_REST_URL,
token: env.UPSTASH_REDIS_REST_TOKEN,
}),
logger,
});Import paths
| Use case | Import |
|---|---|
| Cache factory and helpers | @g14o/cache |
| Memory / Upstash / Redis stores | @g14o/cache/memory, @g14o/cache/upstash, @g14o/cache/redis |
| Redis / env helpers | @g14o/cache/config |
Next steps
- Setup — stores, TTL overrides, build behavior
- Examples —
withCache, SWR, negative caching - API reference