ASP.net 2.0 Cache Translation Draft

Source: Internet
Author: User
Tags interface table name
Asp.net| Cache

Namespaces: System.Web.Caching, this space is an important part of the ASP.NET infrastructure, such as: The session is stored in the cache.

The cache object has two levels of access control: public and private. Private is reserved for use by system components; only public is the interface left to the programmer, and you can use the IEnumerable interface to enumerate the data in the public state.

The ASP.net provides 3 levels of cache:

Page level---cache the entire pages;
Page fragment---can cache controls such as. ASCs, which are part of the cache;
Programmatic caching---cache data through the public cache API;

The caching mechanism of page level in ASP.net 2.0 is extended to support the caching of dependent databases. That is, you can set page level pages cache data and data in database tables to be dependent. The page level cache is automatically invalidated when data changes in the datasheet, which resolves the difficulty of controlling page level caching time.

Look at an example:

Code for page level in asp.net 1.x:

<%@ OutputCache duration= "3600" varybyparam= "ProdID"%>

Code for page level in asp.net 2.0:

<%@ OutputCache duration= "3600" varybyparam= "ProdID" sqldependency= "Northwind:products"%>

Note: Although the page's cache time is 3,600 seconds, if the Northwind:products table data changes, then the cache is invalidated.

Description: SqlDependency is a new property, composed of 2 parts: Data source and table name, configured in: Web.config, see related documents.

ASP.net 2.0 also provides two cache-related classes for SqlCacheDependency and CacheDependency.



Related Article

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.