Cache of data source controls in ASP. NET

Source: Internet
Author: User

Blog SeriesArticle: Learn about the SQL cache of the data source control in the cache & sqlcachedependency section of ASP. NET 2.0 (C #) (4:

Set the following attributes for the datasource control: enablecaching = "true" sqlcachedependency = "cachetest: cachetest" cacheduration = "infinite"

For sqlserver2005, change it to sqldependency = "commandnotification"

Note the configuration in the configuration file

I tested it and summarized two points:

1. As long as the data source control adopts the following Configuration:

Code
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "  
Selectmethod
= " Getcachetests "
Typename
= " Sqlcache. BLL. cachetest "  
Enablecaching
= " True "  
Cacheduration
= " 10 "  
Sqlcachedependency
= " Commandnotification " >
</ ASP: objectdatasource >

 

No additional things are required for both SQL2000, 2005, and 2008, and the configuration file does not need to write anything.

2. If the data source control is configured as follows:

Code
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "  
Selectmethod
= " Getcachetests "
Typename
= " Sqlcache. BLL. cachetest "  
Enablecaching
= " True "  
Cacheduration
= " 10 "  
Sqlcachedependency
= " Cachetest: cachetest " >
</ ASP: objectdatasource >
Or
< ASP: objectdatasource ID = " Objectperformance1 " Runat = " Server "  
Selectmethod
= " Getcachetests "
Typename
= " Sqlcache. BLL. cachetest "  
Enablecaching
= " True "  
Cacheduration
= " Infinite "  
Sqlcachedependency
= " Cachetest: cachetest " >
</ ASP: objectdatasource >

 

Whether it is SQL2000, 2005, or 2008, the configuration file must be written as follows:

Code
< Caching >
< Sqlcachedependency Enabled = " True " Polltime = " 10000 " >
< Databases >
< Add name = " Cachetest " Connectionstringname = " Mssqlconnstring "   />
</ Databases >
</ Sqlcachedependency >
// If it is sqlserver2005, you only need to set it as follows, because sqlserver supports notification-based cache failure.
// <Sqlcachedependency enabled = "true"/>
// If the number is 7th rows, it is incorrect.
</ Caching >

 

You must also use the aspnet_regsql.exe tool to notify the database.

My testsCode: Sqlcache.rar

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.