Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SqlDependency vs SqlCacheDependency

Tags:

sql

asp.net

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.

like image 936
Curtis White Avatar asked Oct 11 '10 20:10

Curtis White


1 Answers

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.

like image 81
Remus Rusanu Avatar answered Oct 05 '22 13:10

Remus Rusanu