asp.net 2.0 (C #) (4)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.