ASP. NET 2.0 cache translation draft

Source: Internet
Author: User

ASP. NET 2.0 cache translation draft


Original article: http://www.codeproject.com/useritems/Caching_Mechanism.asp

Namespace: system. Web. caching, which is an important part of the infrastructure of ASP. NET. For example, session is stored in the cache.

Cache objects have two levels of access control: public and private. Private is reserved by system components. Only public is reserved.ProgramYou can use the ienumerable interface to enumerate data in the public state.

ASP. NET provides 3 intermediate cache:

? Page Level --- cache the entire page;
? Page fragment --- controls such as. ASCs can be cached as part of the page;
? Programmatic caching --- programming to cache data through the public cache API;

In ASP. NET 2.0, the page level cache mechanism is extended to support the cache of dependent databases. That is, the page
The cache data on the level page and the data in the database table are set to dependent. When the data in the data table changes, the page level cache will automatically expire, which solves the problem of page
The level cache time is difficult to control.
Let's look at an example:
In ASP. NET 1.xCode:
<% @ Outputcache duration = "3600" varybyparam = "prodid" %>
Page Level Code in ASP. NET 2.0:
<% @ Outputcache duration = "3600" varybyparam = "prodid" sqldependency = "northwind: Products" %>
Note: although the cache time for the page is 3600 seconds, if the data in the northwind: Products table changes, the cache will become invalid.
Description: sqldependency is a new attribute, which consists of two parts: data source and table name. It is configured in: Web. config. For details, see the relevant documentation.

ASP. NET 2.0 also provides two cache-related classes: sqlcachedependency and cachedependency.

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.