简体   繁体   English

NHibernate每个表的不同会话生存期

[英]NHibernate different session lifetime per table

I'm running a wpf app. 我正在运行一个wpf应用程序。 With a nhibernate session you only have to query a table once and you can access it as many times as you like from cache. 使用nhibernate会话,您只需要查询一个表,就可以从缓存中访问任意多次。

But i like to cache some tables through the entire app because they almost never change, like users and usergroups. 但是我喜欢在整个应用程序中缓存一些表,因为它们几乎永远不会改变,例如用户和用户组。 Should i use one session for the entire app or is there another solution? 我应该为整个应用程序使用一个会话还是有另一种解决方案?

The cache that NHibernate provides as part of the session is referred to as the first level cache. NHibernate作为会话的一部分提供的缓存称为第一级缓存。

For caching things longer than the duration of a session, you need to take a look at the second level cache . 要缓存比会话持续时间更长的内容,您需要查看二级缓存 NHibernate ships with implementations for several cache providers (memcached, SysCache, etc.). NHibernate附带了几个缓存提供程序(memcached,SysCache等)的实现。

Here's an excellent article on how to configure the 2nd level cache using FluentNHibernate 这是一篇关于如何使用FluentNHibernate配置二级缓存的优秀文章

http://www.markhneedham.com/blog/2010/06/16/fluent-nhibernate-and-the-2nd-level-cache/ http://www.markhneedham.com/blog/2010/06/16/fluent-nhibernate-and-the-2nd-level-cache/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM