BodySense Redis 从零到一课程 MOC
以 BodySense 真实 Redis 实现为载体的 12 课学习地图,课程笔记保存教学过程,稳定知识回流到 Redis、认证、缓存、消息与可靠性知识笔记。
[!info] related notes
- 父 MOC:Backend 常用中间件与基础设施 MOC、BodySense 项目 MOC
- 核心知识:Redis
- 缓存:Caching MOC
- 消息:Messaging & Queues MOC
- 实践:Redis 在 Go 后端的应用
BodySense Redis 从零到一课程 MOC
[!abstract] 课程定位 这是一套项目驱动、可脱离聊天独立自学的完整教学稿。课程笔记负责“怎么学”:重要概念第一次出现时必须从定义、动机、最小模型、例子、机制、边界一路讲到 BodySense 真实实现;保留逐步推导、Prediction、折叠答案、实验和故障题。普通知识笔记负责“学完后长期怎么复习”:去掉教学过程,只保留稳定定义、机制、边界与工程结论。
[!important] 完整教学稿标准 课程不是知识摘要。看到一个陌生术语时,不应该被迫先跳到别的笔记才能知道它是什么。例如第 4 课引入 Lua 时,会先解释 Lua 是什么语言、为什么 Redis 内嵌 Lua、代码在哪里执行、
EVAL / KEYS / ARGV / redis.call如何工作、为什么脚本原子、与MULTI/EXEC/WATCH/Functions有什么区别,然后才进入 BodySense 的 Rate Limit / Session / Refresh Rotation 脚本。
课程总览
filters:
and:
- 'file.ext == "md"'
- 'file.inFolder("z")'
- 'file.path.startsWith("z/bodysense-redis-course-")'
- 'file.path != this.file.path'
formulas:
knowledge: 'file.asLink(title)'
properties:
formula.knowledge:
displayName: 课程
note.lesson:
displayName: Lesson
note.lesson_status:
displayName: Status
note.description:
displayName: Description
views:
- type: table
name: 课程总览
order:
- note.lesson
- formula.knowledge
- note.lesson_status
- note.description
columnSize:
note.lesson: 56
formula.knowledge: 340
note.lesson_status: 110
note.description: 680
当前进度
| 课次 | 主题 | 学习状态 | 课程笔记 |
|---|---|---|---|
| 1 | Redis 心智模型、Cache 与 Fast State Plane | ✅ complete | [[bodysense-redis-course-01-mental-model |
| 2 | String、Hash、Set 与 Session 建模 | ✅ complete | [[bodysense-redis-course-02-data-structures |
| 3 | TTL、Expiration 与 Eviction | ✅ complete | [[bodysense-redis-course-03-ttl-expiration-eviction |
| 4 | 原子性、Race Condition、MULTI/WATCH/Lua | 🟡 in-progress | [[bodysense-redis-course-04-atomicity-lua |
| 5 | Session Authority:JWT 为什么仍然需要 Redis | ⬜ planned | [[bodysense-redis-course-05-session-authority |
| 6 | Rate Limiting | ⬜ planned | [[bodysense-redis-course-06-rate-limiting |
| 7 | Persistence:RDB / AOF / Recovery | ⬜ planned | [[bodysense-redis-course-07-persistence |
| 8 | Cache Aside 与 Cache Correctness | ⬜ planned | [[bodysense-redis-course-08-cache-correctness |
| 9 | Pub/Sub 与实时通知 | ⬜ planned | [[bodysense-redis-course-09-pubsub |
| 10 | Redis Streams / Queue / Worker | ⬜ planned | [[bodysense-redis-course-10-streams-queue-worker |
| 11 | Redis Operations & Observability | ⬜ planned | [[bodysense-redis-course-11-operations-observability |
| 12 | Failure Engineering & Capacity | ⬜ planned | [[bodysense-redis-course-12-failure-capacity |
教学方法
每一课统一采用:
前置回顾
→ 新概念从零解释:是什么 / 为什么需要
→ 最小工作模型与最小例子
→ 机制、因果链、相邻概念区别
→ BodySense 真实代码 / 状态映射
→ Prediction(先自己回答)
→ 折叠 Answer / 解析
→ Redis CLI / isolated lab
→ Failure Injection
→ Explain-back
→ L4 verification
[!tip] 建议学习方式 每一课先读到 Prediction,不要立即展开答案;先在脑中或笔记里写出判断与理由,再展开折叠的
Answer / 解析对照。最后完成 Lab / Failure Injection 和 Explain-back / L4 Gate。“看过”不算完成。能够预测行为、解释 BodySense 的真实实现、说明故障语义,并通过实验或代码证据验证,才算进入 L4。
课程笔记与知识笔记的分工
课程笔记 type/course
├─ 教学顺序
├─ 逐步推导
├─ Prediction
├─ 实验
├─ BodySense 场景
└─ 可以为了理解重复
知识笔记 concept / synthesis / howto / debug
├─ 稳定定义
├─ 核心机制
├─ 工程边界
├─ 速查
└─ 避免课程式重复
课程中形成的新结论应回流到知识笔记;知识笔记更新后,课程笔记只需要保持链接和教学连贯性。
核心知识入口
- Redis:整体心智模型、数据结构、TTL、持久化、原子性、消息与运维边界。
- Redis Expiration 与 Eviction:TTL 到期与内存淘汰的语义差异。
- Redis 原子性、事务与 Lua:单命令原子性、多步竞态、MULTI/WATCH/Lua。
- Redis Session Authority:JWT 与服务端在线授权状态的组合。
- Refresh Token:Rotation、Replay Detection 与服务端状态。
- Go 限流、限流响应头。
- Redis RDB、AOF 与恢复。
- 缓存策略与一致性。
- Redis Pub/Sub。
- Redis Streams。
- Redis 运维、观测与故障语义。
BodySense 的总架构心智模型
PostgreSQL
= Durable Truth / Audit / Replay / Recovery
Redis
= Shared Fast State / Cache / Coordination
/ Realtime Notification / Wakeup Plane
[!warning] 永久保护的边界 BodyState、Diagnosis、Treatment、Runtime Event durable log、Job ledger 等需要事务、历史审计、回放和恢复的状态,不因为 Redis 更快就迁成 Redis-only truth。