Cache Feishu retrieval data in Redis

This commit is contained in:
2026-07-08 17:39:04 +08:00
parent 70466a6a31
commit c68af6f806
3 changed files with 116 additions and 0 deletions

View File

@@ -418,3 +418,37 @@
1. 当前 Redis 队列使用轮询晋升等待请求,下一步可以结合 Pub/Sub 或 blocking pop 降低等待侧轮询。
2. Redis 飞书共享缓存还未接入,将在阶段 4B 完成。
3. 生产部署需要确认 Redis 持久化、内存上限、淘汰策略和监控告警。
## 阶段 4B 实施记录
2026-07-08 完成 Redis 飞书共享缓存第一版。
已完成:
1. 新增 `redis_cache_service`,提供 Redis 文本和 JSON 缓存读写 helper。
2. 用户端 async 飞书/RAG 链路已接入 Redis 缓存:
- tenant token。
- Wiki node info。
- Wiki children。
- Docx 文本内容。
- Drive file 文本内容。
3. 缓存 key 按飞书应用凭证 hash 和资源 token 隔离。
4. Redis 不可用或缓存读写失败时自动降级,不阻断问答主流程。
5. 保留进程内缓存作为本进程内的一级缓存Redis 作为跨 worker / 跨实例共享缓存。
验证记录:
1. 本机 `compileall` 检查通过。
2. `git diff --check` 通过。
3. 容器内 `compileall` 检查通过。
4. 容器内 Redis 文本和 JSON 缓存读写验证通过。
5. 后端健康检查通过。
6. 真实 `/chat/completions` 验证通过:首个事件为 `generating`,随后返回 `content`,最后返回 `[DONE]`
7. 真实会话历史验证通过:流式完成后用户消息和助手消息均已落库。
8. 真实问答后 Redis 中已生成飞书缓存 key。
阶段限制:
1. 当前 Redis 缓存 TTL 仍复用进程内缓存的 5 分钟默认值。
2. 同步旧飞书链路暂未接入 Redis 缓存,用户端 async 问答链路已接入。
3. 后续可以在系统设置开放飞书缓存 TTL、缓存清理和单知识库刷新能力。