Files
saasshop/docs/REDIS_CACHE_PLAN.md

41 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Redis 缓存接入计划
## 当前阶段
- 默认缓存驱动已切换为 `redis`
- 优先接入商家后台高频读场景
- 商家仪表盘统计
- 商家商品列表
## 当前缓存 Key 设计
- `merchant:{merchantId}:dashboard:stats`
- `merchant:{merchantId}:products:list`
配合 `.env` 中的:
- `CACHE_STORE=redis`
- `CACHE_PREFIX=saasshop-cache-`
实际 Redis 中最终 key 会叠加 Laravel 前缀,避免与其他项目冲突。
## TTL 策略
- 商家仪表盘统计10 分钟
- 商家商品列表10 分钟
## 失效策略
- 商品新增 / 更新 / 删除:
- 清理 `merchant:{merchantId}:products:list`
- 清理 `merchant:{merchantId}:dashboard:stats`
- 订单状态更新:
- 清理 `merchant:{merchantId}:dashboard:stats`
## 设计原则
1. key 必须带 merchant 维度,避免跨商家串缓存
2. 优先缓存读多写少页面,不先缓存复杂写流程
3. 失效优先正确,再追求更细粒度
4. 后续可扩展:分类列表缓存、总台管理统计缓存、配置缓存预热
## 下一步建议
1. 给商品分类列表增加单独缓存
2. 给总台管理仪表盘增加缓存层
3. 评估是否引入 tag如果后续缓存驱动与场景需要
4. 后续把订单列表也纳入缓存,但要先设计分页和筛选条件 key 规范