Asp.net|cache|sql
Previously used cache, always beware of the data version of the cache and the database version of the data is inconsistent, although through the trigger + file IO Implementation of the file cache can also achieve cache data updates, but each application produces an IO file, not economical, the other trigger performance is not very high, So often in addition to delete changes, delete the cache key value to achieve, but there may be missing places. SqlCacheDependency is implemented in ASP.net 2.0, this article describes how to implement SqlCacheDependency in asp.net 2.0:
First, add the following code to the Web.config system.web node file:
<caching>
<sqlcachedependency enabled= "true" >
<databases>
<add name= "Atlasdemodb" connectionstringname= "atlasdemodbconnectionstring" polltime= "12000" ></add>
</databases>
</sqlCacheDependency>
</caching>
This configures a cache-dependent database, and the ObjectDataSource object's enablecaching on the page is set to True., and then set the SqlCacheDependency property to Atlasdemodb: Simpledemo1,atlasdemodb the name of the cached database configured for web.config, SimpleDemo1 is a table name under that database.
In this way, the system will also have the following problems:
Database "Atlasdemodb" is not enabled for SQL cache notification.
To enable the database for SQL cache notification, use the System.Web.Caching.SqlCacheDependencyAdmin.EnableNotifications method, or the command-line tool aspnet_regsql. To use this tool, run the aspnet_regsql.exe-? For more information.
According to the above, run aspnet_regsql.exe more annoying, you can fill in the Page_Load event
System.Web.Caching.SqlCacheDependencyAdmin.EnableTableForNotifications ( system.configuration.configurationmanager.connectionstrings["Atlasdemodbconnectionstring"]. ConnectionString, "SimpleDemo1");
This will allow you to use the SqlCacheDependency.