在 NHibernate 二级缓存之上使用 ASP.NET 缓存

发布于 2024-08-22 17:05:23 字数 58 浏览 2 评论 0原文

我是否应该考虑使用 ASP.NET 缓存在 NHibernate 二级缓存之上缓存查询结果以提高性能?

Should i consider using ASP.NET Caching to cache query results on top of NHibernate 2nd Level Caching to improve performances ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紫瑟鸿黎 2024-08-29 17:05:23

我认为 NHibernate 二级缓存就足够了。使用 asp.net 缓存来缓存相同的查询结果不需要额外的开销。但如果您需要终极性能,您可以使用 IIS 内核缓存(本机输出缓存)。我还建议您使用 NHibernate Profiler 来分析您的应用程序。它将显示缓存未命中以及有关查询的大量有用信息以及一些好的建议。

编辑:
NHibernate.SysCache2 使用 ASP.NET 缓存,速度稍慢,因为它支持基于 SQL 依赖项的过期,这意味着可以将某些缓存区域配置为在数据库中的相关数据发生更改时自动过期。
您也可以尝试缓存您的 ViewModel。但是,如果您可以缓存它们,那么您也可以缓存生成的视图,这会更好更快。这篇文章可能对您有帮助 - http://haacked .com/archive/2009/05/12/donut-hole-caching.aspx

I think it's enough ot NHibernate 2nd level cache. There are no need for additional overhead by using asp.net caching to cache the same query results. But if you need ultimate performance you can cache your rendered pages and controls using IIS Kernel cache (native output cache). And also I recommend you to profile your application using NHibernate Profiler. It'll show cache misses and a lot of useful information about your queries with some good recommendations.

Edit:
NHibernate.SysCache2 uses ASP.NET cache and it is a bit slower because it supports SQL dependency-based expiration, meaning that it is possible to configure certain cache regions to automatically expire when the relevant data in the database changes.
Also you can try to cache your ViewModels. But if you can cache them then you also can cache the generated views which is much better and faster. And this article may be helpful for you - http://haacked.com/archive/2009/05/12/donut-hole-caching.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文