How to enable SQL cache dependency in ASP.NET 2.0?

I think there are several steps to enable SQL Cache Depdndency:

Turn on notifications, changes to web.xml, and then use the Cache dependency object.

Please help, how can I get through them?

+4
source share
2 answers

Check out this post . This will help you with the Aspnet_regsql.exe tool that installs it for you.

Here is an excerpt from the above message:

...To enable a cache dependency on a particular database, run this command: aspnet_regsql.exe -S server -U user -P password -d database -ed This creates a new table, AspNet_SqlCacheTablesForChangeNotification, in the designated database. Next, several AspNet_SqlCacheXxxx stored procs are created in the same database. 

Then check out this post from MSDN for an overview, with lots of How-to links.

+3
source

To enable a table to use SQL cache dependencies, you first need to run the aspnet_regsql.exe tool from the command line with these parameters:

 aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t tablename 

If your table name contains a space, then wrap the table name in quotation marks, for example.

 aspnet_regsql -S servername -U login -P password -ed -d databasename -et -t "table name" 

In your web.config you need to add the caching section:

 <system.web> <caching> <sqlCacheDependency enabled = "true" pollTime = "60000" > <databases> <add name="northwind" connectionStringName="Northwind" pollTime="9000000" /> </databases> </sqlCacheDependency> </caching> </system.web> 

When you add an item to your cache, you use the SqlCacheDependency object to configure the relationship between the cached object and the base table:

 SqlCacheDependency dependency = new SqlCacheDependency("databasename", "tablename"); Cache.Add(key, object, dependency); 
+2
source

Source: https://habr.com/ru/post/1314723/


All Articles