Upstash 是一个完全托管的 Redis 数据库即服务。Upstash 兼容 Redis® API,这意味着你可以使用 Bun 的原生 Redis 客户端连接你的 Upstash 数据库。Documentation Index
Fetch the complete documentation index at: https://bun.zhcndoc.com/llms.txt
Use this file to discover all available pages before exploring further.
所有 Upstash Redis 数据库默认启用 TLS。
创建一个 Upstash Redis 数据库
访问 Upstash 控制台 并创建一个新的 Redis 数据库。完成快速入门指南后,你会看到数据库页面及其连接信息。数据库页面显示两种连接方式;HTTP 和 TLS。对于 Bun 的 Redis 客户端,你需要使用 TLS 连接详情。该 URL 以 
rediss:// 开头。
使用 Bun 的 Redis 客户端连接
你可以通过设置环境变量,使用 Bun 默认的 Bun 的 Redis 客户端默认从
index.ts另外,你也可以通过
index.ts
redis 客户端连接 Upstash。在你的 .env 文件中设置 REDIS_URL 环境变量,使用 Redis 端点(不是 REST URL):.env
REDIS_URL 读取连接信息:RedisClient 创建自定义客户端: