Implement Redis CHIS session store

This commit is contained in:
ila
2026-07-05 11:35:59 +08:00
parent 83c1100aa8
commit 32037a04e1
12 changed files with 216 additions and 16 deletions
+9
View File
@@ -124,3 +124,12 @@
- 阻塞:无。
- 决策:T-102 只做已有 cookie 的账号信息查询和失效判断;Redis 缓存、清理缓存和重登策略留给 T-103 / T-104。
- 下一步:T-103 实现 Redis 会话缓存。
## 2026-07-05 T-103 实现 Redis 会话缓存
- 状态:DONE
- 变更:新增 `app/chis/session_store.py`,定义 `ChisSession` 和 `RedisChisSessionStore`,支持 Redis `setex/get/delete`、会话 JSON 序列化、按 `expires_at` 计算 TTL、过期会话自动删除;新增 `tests/test_chis_session_store.py`;`requirements.txt` 增加 `redis==3.5.3`;更新任务看板、技术栈、架构、API 合约、当前状态和根目录任务总览。
- 验证:先执行 `python -m pytest tests\test_chis_session_store.py`,看到 `ModuleNotFoundError: No module named 'app.chis.session_store'`;实现后执行同一命令结果 `3 passed`。为固定 Redis 依赖,先执行 `python -m pytest tests\test_project_setup.py` 看到缺少 `redis==5.0.8` 的断言失败;安装时发现系统环境 `django-q` 要求 `redis<4.0.0`,因此改为兼容的 `redis==3.5.3` 并执行 `python -m pip install -r requirements.txt` 成功;执行 `python -m pytest tests\test_project_setup.py tests\test_chis_session_store.py` 结果 `4 passed`。
- 阻塞:无。
- 决策:T-103 只实现会话缓存读写和过期清理;会话验证失败后的清缓存、重登一次和重试一次留给 T-104。由于项目使用系统 Python 且不建虚拟环境,Redis 依赖固定为 `redis==3.5.3`,避免破坏同环境 `django-q` 依赖。
- 下一步:T-104 实现失效重登策略。