知识卡片
CQRS分开写入与读取
CQRS把执行命令的模型作为唯一强一致真源,负责规则、不变量及并发更新;读模型是按查询用途预先计算的投影,只能由投影过程更新,应能从真源重建。查询不得改动任何持久化状态,业务命令也不得绕过命令模型直接修改读库。
结构图:
flowchart TD
A[命令] --> B[强一致命令模型]
B --> C[投影过程]
C --> D[查询模型一]
C --> E[查询模型二]
F[查询] --> D
F --> E
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 架构模式 · 查看原书依据
CQRS devotes a single model to executing operations that modify the system’s state (system commands). This model is used to implement the business logic, validate rules, and enforce invariants. The command execution model is also the only model representing strongly consistent data—the system’s source of truth. It should be possible to read the strongly consistent
参考来源
- 位置:《Learning Domain-Driven Design》第8章《架构模式》(来源项目:book-sources;源文件:extracted/Learning Domain-Driven Design/_epub-src/OEBPS/ch08.html)
- 结论依据:原文围绕本卡所述机制给出定义、适用条件及相关取舍,以下摘录为直接依据。
- 原始内容:CQRS devotes a single model to executing operations that modify the system’s state (system commands). This model is used to implement the business logic, validate rules, and enforce invariants. The command execution model is also the only model representing strongly consistent data—the system’s source of truth. It should be possible to read the strongly consistent