我在NHibernate上阅读Ayende关于期货的帖子并开始使用它。 最初仅针对隔离场景 - 返回分页结果的查询(对单个数据库中的查询和计数项目)。 但是我想为什么不为每一个查询使用期货。 在我的大多数操作方法中,我需要进行多次查询,平均每页5次(获取用户个人资料,页脚,类别,组信息等)。
显而易见的好处是总体上这个查询总结应该花费更短的时间来运行。 但是这样的Web应用程序设计有什么缺点吗? 让我好奇的领域是:
NHibernate中的缓存 - 这种设计会阻止以任何方式使用NHibernate的缓存功能吗? 也许这样的单一包查询会锁定数据库表并使其他并行操作等待? 我使用Read Committed隔离级别。任何其他? 你对期货的经历是什么? 您是否会建议以这种方式使用它,以及每个可能的项目?
I read Ayende post about Futures in NHibernate and started using it. At first only for isolated scenario - queries that return paged results (to both query and count items in single trip to database). But than I thought why not to use futures for every single query. In most of my action methods I need to make multiple queries, on average 5 per page (to get user profile, footer, categories, group information etc).
Obvious benefit is that overall this queries summed up should take shorter to run. But are there any drawbacks for such design of web application? Areas that make me curious are:
Caching in NHibernate - will this design prevent in any way of using caching features of NHibernate? Maybe such single pack of queries will lock database tables and make other parallel actions wait? I use Read Committed isolation level.Any other? What are your experiences with futures? Would you recommend using it in such a way, to every possible item?
最满意答案
您的疑虑将不适用。 缓存不会被破坏,锁定表只是批量读取语句非常罕见。
期货摇滚,我希望我使用的每一个ORM都有它们。
Your concerns won't apply. Caching won't be broken and its pretty rare to lock tables just batching up read statements.
Futures rock and I wish every ORM I use had them.
更多推荐
发布评论