SqlDependency vs SqlCacheDependency

走远了吗. 提交于 2019-12-21 04:34:09

问题


What are the key differences between these and when should they be used? My initial understanding was that SqlCacheDependency used polling but I've read it doesn't have too for ASP.NET 2.0. I want to know which is most appropriate for caching of linq queries under ASP.NET web server. This will be ASP.NET 3.5.

  • SqlCacheDependency on forum
  • SqlCacheDependency
  • SqlDependency

The SqlCacheDependency class also supports integration with the System.Data.SqlClient.SqlDependency class when using a SQL Server 2005 database. The query notification mechanism of SQL Server 2005 detects changes to data that invalidate the results of an SQL query and removes any cached items associated with the SQL query from the System.Web.Caching.Cache.


回答1:


Query Notification is the underlying technology. SqlNotificationRequest is the ADO.Net client support. SqlDependency is the ADO.Net infrastructure to automate the deployment of temporary objects needed by SqlNotificationRequest. SqlCacheDependency uses SqlDependency to integrate it with the ASP caching infrastructure. See more at The Mysterious Notification.

Note on them work with LINQ. See LinqToCache for a project that leverages Query Notifications with LINQ queries, and also explains why the vast majority of LINQ queries cannot use Query Notifications.



来源:https://stackoverflow.com/questions/3909626/sqldependency-vs-sqlcachedependency

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!