mirror of
https://github.com/lobehub/lobe-chat.git
synced 2026-06-14 03:30:19 +00:00
70 lines
2.0 KiB
Plaintext
70 lines
2.0 KiB
Plaintext
---
|
||
title: 配置 Upstash Redis 服务
|
||
description: 详细指南:如何配置 Upstash Redis 用于 LobeChat 的缓存和会话存储。
|
||
tags:
|
||
- Upstash
|
||
- Redis
|
||
- 缓存
|
||
- 配置指南
|
||
---
|
||
|
||
# 配置 Upstash Redis 服务
|
||
|
||
[Upstash](https://upstash.com/) 是一个 Serverless Redis 服务,提供免费额度和按量付费模式,非常适合 LobeChat 部署使用。
|
||
|
||
## 配置步骤
|
||
|
||
<Steps>
|
||
### 在 Upstash 创建 Redis 数据库
|
||
|
||
1. 访问 [Upstash 控制台](https://console.upstash.com/) 并注册
|
||
2. 点击 **Create Database**,配置:名称、区域、启用 TLS
|
||
3. 从数据库详情页复制 **Redis URL**(TCP 连接方式,不是 REST API):
|
||
|
||
<Image alt={'从 Upstash 复制 Redis URL'} src={'https://hub-apac-1.lobeobjects.space/docs/43d110283ba816c0c2b45408e4f9d344.png'} />
|
||
|
||
### 配置环境变量
|
||
|
||
```shell
|
||
# Upstash Redis URL(从 Upstash 控制台复制)
|
||
REDIS_URL=rediss://default:xxxxxxxxxxxxx@us1-xxxxx-xxxxx.upstash.io:6379
|
||
|
||
# 可选:启用 TLS(Upstash 推荐)
|
||
REDIS_TLS=1
|
||
|
||
# 可选:设置 Redis 键前缀
|
||
REDIS_PREFIX=lobechat
|
||
```
|
||
|
||
<Callout type={'info'}>
|
||
Upstash 使用 `rediss://`(双 's')表示 TLS 连接,LobeChat 自动支持此格式。
|
||
</Callout>
|
||
</Steps>
|
||
|
||
## 环境变量概览
|
||
|
||
```shell
|
||
# Upstash Redis 连接 URL
|
||
REDIS_URL=rediss://default:xxxxxxxxxxxxx@us1-xxxxx-xxxxx.upstash.io:6379
|
||
|
||
# 可选:启用 TLS 加密(Upstash 推荐)
|
||
REDIS_TLS=1
|
||
|
||
# 可选:键前缀,用于数据隔离
|
||
REDIS_PREFIX=lobechat
|
||
```
|
||
|
||
## 注意事项
|
||
|
||
<Callout type={'tip'}>
|
||
Upstash 提供慷慨的免费额度:每天 10,000 次命令,足够个人使用和小规模部署。
|
||
</Callout>
|
||
|
||
<Callout type={'warning'}>
|
||
请确保安全保管你的 Redis URL,切勿在客户端代码或公开仓库中暴露。
|
||
</Callout>
|
||
|
||
- **免费额度限制**:每天 10,000 次命令,256MB 存储
|
||
- **TLS 必需**:Upstash 要求 TLS 连接,确保设置 `REDIS_TLS=1`
|
||
- **Regional vs Global**:如果用户分布全球,选择 Global 可获得更低延迟
|