Skip to content
全部能力
集成packages/integrations/cache

cache 能力包

基于 tag 的缓存 — Redis / Upstash / 内存 三种 backend;serverless 与自托管复用同一 get/set/invalidate(tags) 接口。

打开文档
稳定性
稳定
作用域
全局
边界
packages/integrations/cache
缓存可观测性
Upstash Redisus-east-1

命中率

94.7%

+2.1%

延迟 p50

1.2ms

−0.3ms

延迟 p99

8ms

+1.0ms

内存

847MB

/ 2GB

命中比
近 5 分钟
已用内存847 MB / 2 GB
x
最近键TTL大小
  • user:abc123:profileHIT58s4.2 KB
  • session:xyz789HIT12m1.1 KB
  • org:42:billingMISS0 B
  • post:9c1f:metaHIT5m812 B
  • rate:ip:10.0.2HIT47s64 B
  • feed:home:v3MISS0 B
使用方式cache.ts
typescript
cache.ts
1import { getCache } from "@nebutra/cache";
2
3const cache = await getCache();
4
5const user = await cache.fetch(`user:${id}`, {
6  ttl: 60,
7  fetcher: () => prisma.user.findUnique({ where: { id } }),
8});
9
10await cache.invalidate(`user:${id}`);