asp.net 2.0 (C #) (4)-Cache&sqlcachedependency (Caching and SqlCacheDependency features)
Introduced
Storage is a technique widely used in computing to improve performance by keeping frequently accessed data or data that has large access costs in memory or on a hard disk. In the context of WEB applications, caching is used to preserve pages or data between HTTP requests, and you can reuse them without wasting resources recreating them.
The essential
1, @OutputCache the attributes in the directive:
Duration-Cache time (seconds)
VaryByParam-Changes the cached result based on a name/value pair sent using POST or get (multiple parameters separated by semicolons)
VaryByControl-Changes the cached fragment based on the controls in the user control (the value is the control ID and the multiple controls are separated by semicolons)
CacheProfile-The cache time set in the call configuration file
2, increase the data cache with Cache.Insert, you can specify the cache time
3, replace cache (substitution)-callback function if static
4, SqlCacheDependency
Configuration in the configuration file
<system.web>
<caching>
<sqlcachedependency enabled= "true" polltime= "polling Time (ms)" >
;d atabases>
<add name= "name" connectionstringname= "Connection string name"/>
</databases>
</sql Cachedependency>
<!--If SqlServer2005 is the case, only the following settings are required because SQL Server supports notification-based cache invalidation
<sqlcachedependency Enabled= "true"/>
-->
</caching>
</system.web>
If it's not SqlServer2005, you should use Aspnet_regsql to register.
Aspnet_regsql.exe-s "Server"-e-d "database"-ed
aspnet_regsql.exe-s "server"-e-d "database"-et-t "table"
If it is SQL verification, you should replace-E with-u (username),-p (password)