知识卡片
聚合内不变量随事务检查
不变量是数据变化后始终要满足的一致性规则。聚合(参见[[聚合根限定外部引用]])的边界就是一次事务必须同步维护这类规则的范围:提交内部任一对象的修改前,整个聚合的不变量都应成立。跨聚合依赖则不默认实时同步,可按规定时限通过事件、批处理等机制解决。边界须按业务关联与变更频率选择:划太小会漏掉必须同验的规则,划太大则增加锁争用。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 原书第06章|Aggregates · 查看原书依据
Invariants, which are consistency rules that must be maintained whenever data changes, will involve relationships between members of the AGGREGATE. Any rule that spans AGGREGATES will not be expected to be up-to-date at all times.
参考来源
- 位置:《Domain-Driven Design: Tackling Complexity in the Heart of Software》第44章《原书第06章|Aggregates》(源文件:_epub-src/0321125215_ch06lev1sec1.html;图6.3)
- 结论依据:原文定义不变量,规定聚合内每次事务提交时强制满足,跨聚合规则可延后解决,并在引入部分说明边界须权衡争用与严格规则。
- 原始内容:Invariants, which are consistency rules that must be maintained whenever data changes, will involve relationships between members of the AGGREGATE . Any rule that spans AGGREGATES will not be expected to be up-to-date at all times. ... But the invariants applied within an AGGREGATE will be enforced with the completion of each transaction.