@prismakit/redis
v4.0.0
Published
Redis CacheAdapter for @prismakit/core
Maintainers
Readme
@prismakit/redis
Redis CacheAdapter for @prismakit/core repositories (ioredis).
Fail-open: cache errors do not break reads/writes.
Status: pre-stable (4.0).
Documentation · Cache guide · GitHub
Install
pnpm add @prismakit/redis ioredisUsage
import { RedisCacheAdapter } from '@prismakit/redis';
const cache = new RedisCacheAdapter({
url: process.env.REDIS_URL, // or host + port
prefix: 'myapp',
});Options
| Option | Default | Description |
|--------|---------|-------------|
| url | — | Redis connection URL |
| host | localhost | Used when url is omitted |
| port | 6379 | Used when url is omitted |
| prefix | prismakit | Key prefix for all cache keys |
Wire it up
Core
const users = new UserRepository({ prisma, cache });NestJS
PrismaKitModule.forRoot({
prisma,
cache: new RedisCacheAdapter({ prefix: 'myapp' }),
});JSON codec
Tagged JSON for Date, BigInt, Bytes, and Prisma Decimal. Custom revive:
import { createRedisJsonReviver } from '@prismakit/redis';
const reviver = createRedisJsonReviver({ /* DecimalFactory? */ });Cache debug (CACHE_DEBUG=true, cacheDebugStorage, …) lives on @prismakit/core.
Cache behavior (reminder)
- Reads cache only when
setCache: true - Never cache auth / sensitive selects
- Inside transactions: skip cache; invalidate in
afterCommit
Docs
License
Apache-2.0
