NHibernate的缓存问题 - 当调用集中退出? [英] NHibernate caching issue - When to call Evict?

查看:89
本文介绍了NHibernate的缓存问题 - 当调用集中退出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我碰到哪里是什么的被返回的NHibernate一个明显的缓存问题是不是与什么是在数据库匹配起来。

I've run into an apparent caching issue where what's being returned by NHibernate is not matching up with what's in the DB.

我相信这是二级缓存的数据。它看起来像我可以使用集中退出要做到这一点,但时,应集中退出方法实际上被调用?对于我的实际应用中,数据将是对用户唯一机会是提供的数据只会一次*使用。

I believe this is level2 cache data. It looks like I can use the Evict to do this, but when should the Evict method actually be called? For my particular application, the data is going to be unique to the user and chances are the data provided will only be used once*.

我可以禁用缓存2级别为这些对象集的完全?

更新10/31

我的情况是这样的:我有凡客将是添加和删除项目的购物车。什么我做的是以下几点:处理到购物车更新之前,我退出的 CartProduct 实体。一旦做到这一点,我从供应商获取 CartProducts 的列表,并返回视图(这是在.NET MVC控制器发生)。

My scenario is this: I have a shopping cart where the customer is going to be adding and removing items. What I am doing is the following: before the updates to the cart are processed, I evict the Cart and CartProduct entities. Once this is done, I retrieve the list of CartProducts from the provider and return the view (this is happening in a .NET MVC Controller).

更新11/3

的购物车已经被完成了,我跑进那似乎是与同一NHibernate的问题的问题,但实际上是一个MVC的问题。更深层次的挖透露,HTML辅助扩展覆盖了我以为的价值,什么是模型的状态替换。所以在这一个双重打击。希望这可以帮助别人。

The shopping cart has since been finished, and I ran into an issue that appeared to be related to the same NHibernate issue, but in fact was an MVC issue. Deeper digging revealed that the HTML Helper extensions were overriding the value I supposed and replacing with what was in the Model state. So a double whammy on this one. Hope this helps someone.

推荐答案

没有,你不能禁用某些实体缓存。

No, you cannot disable the cache for certain entities.

您这样做有几个选项:


  1. 使用ISession.Clear()来清除所有实体从NHibernate的缓存。
  1. Use ISession.Clear() to clear all entities from NHibernate's cache.
    • http://nhibernate.info/doc/nh/en/index.html#performance-sessioncache
  • http://nhibernate.info/doc/nh/en/index.html#performance-sessioncache
  • http://nhibernate.info/doc/nh/en/index.html#performance-sessioncache
  • http://nhibernate.info/doc/nh/en/index.html#batch-statelesssession

这篇关于NHibernate的缓存问题 - 当调用集中退出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆