【发布时间】:2021-07-25 14:58:22
【问题描述】:
我是marten的新手。IDocumentStore.OpenSession() 与 IDocumentStore.LightweightSession() 有什么区别?
【问题讨论】:
标签: c# postgresql nosql marten
我是marten的新手。IDocumentStore.OpenSession() 与 IDocumentStore.LightweightSession() 有什么区别?
【问题讨论】:
标签: c# postgresql nosql marten
基于 xml doc 这只是一种方便的方法:
在没有 IdentityMap 或自动脏检查的情况下创建新的“轻量级”IDocumentSession 的便捷方法
在当前实现中,它只是将calls OpenSession 与DocumentTracking 设置为DocumentTracking.None。
同样来自troubleshooting docs:
来自
IDocumentStore.OpenSession特点:
默认为通过对象的身份跟踪对象的会话,
DocumentTracking.IdentityOnly,隔离级别为 Read Committed。使用: 读取和写入数据。会话中的对象按其身份进行缓存。通过会话操作(
IDocumentSession.Update、IDocumentSession.Store)显式控制对对象的更新。使用默认值,产生的开销低于DirtyTrackedSession。
和
来自
IDocumentStore.LightweightSession特点:
没有更改跟踪,
DocumentTracking.None,默认隔离级别为 Read Committed。使用: 读取和写入数据。在会话中不缓存对象,例如使用相同的文档身份重复加载会产生单独的对象,每个对象都从数据库中提取。在对此类对象进行更新的情况下,要存储的最后一个对象将覆盖来自先前存储的具有相同身份的对象的任何未决更改。可以产生比跟踪会话更低的开销。
【讨论】: