gpt4 book ai didi

c# - 如何保持长时间运行的 NHibernate Session 数据一致?

转载 作者:行者123 更新时间:2023-11-30 14:41:49 25 4
gpt4 key购买 nike

我在 ASP.NET session 中缓存了 NHibernate session 。

我遇到过这样一种情况,用户编辑了一个对象,使其位于 ISession 的一级缓存中。然后另一个用户编辑了同一个对象。

此时用户 1 仍然看到他们编辑的原始版本,而用户 2 看到对象的正确状态?

如果不始终为每个对象显式手动调用 session.Refresh(myObj),处理此问题的正确方法是什么?

我还启用了二级缓存。对于 NHibernate Long Session,我应该完全禁用一级缓存吗?

编辑:为我希望从 10.4.1. Long session with automatic versioning 实现的目标添加更多术语本节的结尾以

结尾

As the ISession is also the (mandatory) first-level cache and contains all loaded objects, we can propably use this strategy only for a few request/response cycles. This is indeed recommended, as the ISession will soon also have stale data.

我不确定这是什么类型的文档,因为它可能包含两者,然后立即说 session 将包含陈旧数据(这就是我所看到的)。这里有什么解决方案,还是没有解决方案?

最佳答案

关于c# - 如何保持长时间运行的 NHibernate Session 数据一致?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3754592/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com