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.