: Establish a Connection object, create a SqlCommand instance, create an SqlCacheDependency instance, and then invoke the command object to fetch the data (this order is important). Then invoke the cache INSERT statement to establish a cache entry that relies on a specific query dataset.
SqlConnection conn = new SqlConnection (strconnection);
SqlCommand command = new SqlCommand (STRCOMMANDTEXT, conn);
SqlCacheDependency dependency = new SqlCacheDependency (command);
Registers the method to the
, COUNT (*), MAX, MIN, STDEV, STDEVP, VAR, or VARP.
The statement cannot use any of the nondeterministic functions, including the Rank function and the window-opening function.
Statement cannot contain user-defined aggregations.
Statements cannot reference system tables or views, including catalog views and dynamic management views.
The statement cannot contain the for BROWSE information.
Statement cannot reference a queue.
Statements cannot contain conditional statements (such as WH
communicate with the service, which in turn knows how to communicate back to call the corresponding entity. In fact, these queues and services are some of the same class objects as tables, views, and stored procedures. Although Service Broker can be used entirely within SQL Server, Ado.net knows how to communicate with Service Broker to trigger this mechanism and retrieve notifications from service Broker.
Note When data in SQL Server changes, the query notification allows you to buffer the dat
/library/bb522893 (V = SQL .105). aspx)
Use sqldependency for caching;
Caching is a function that must be involved in every system. Generally, caching has a problem-when to clear it? For example, you can set an expiration time for the cache in ASP. NET, but how long is it appropriate? If it is too long, the meaning of the cache will be lost. This problem can be solved by using sqldependency for caching.
Use the @ outputcache command
Use the @ outputcache command to implement general requirements for page output cache. @ Outputcache command the header Declaration of the user control contained in the ASP. NET page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ Outputcache command DeclarationCodeAs follows.
@ Outputcache command code
As shown above, the @ outputcache command contains 10 attributes, incl
The best and fastest way to improve performance is, of course, to improve performance through caching. Any web developer should make good use of caching. The cache mechanism in Asp.net is very powerful. Using the cache mechanism can greatly improve the performance of Web applications. The following are some summary of the cache knowledge points to share with you:
1. Page Cache
To implement the page output cache, you only need to add an outputcache command to the page.
Cacheprofile= ""Nostore =
You can use either the @ OutputCache command or the page output cache API to set the page output cache. @ OutputCache commands have appeared in ASP. NET 1.x and are inherited and enhanced in ASP. NET 2.0. The page output cache API mainly refers to the HttpCachePolicy class.
Use the @ OutputCache command
Use the @ OutputCache command to implement general requirements for page output cache. @ OutputCache command the header Declaration of the user control contained in the ASP. NET page or page
Use the @ OutputCache command
Use the @ OutputCache command to implement general requirements for page output cache. @ OutputCache command the header Declaration of the user control contained in the asp.net page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ OutputCache command declaration code.
@ OutputCache command code
<%@OutputCacheCacheProfile=""NoStore="True|False"Duration="#ofseconds"Shared="True|Fal
some application scenarios, if you want to update the database, the changes in the cache can take effect immediately. In Asp.net 1.1, it is relatively difficult to implement, in Asp.net 2.0, this function can be conveniently implemented.
2. Preparations before coding
For sqlserver2005(Built-in support for SQL data cache dependencies, built-in notification delivery service, can provide smaller granularity of data change monitoring, easy to use and configure .).
1. Check whether service bro
refers to the httpcachepolicy class.
Use@ OutputcacheCommand
Use the @ outputcache command to implement general requirements for page output cache. @ Outputcache command the header Declaration of the user control contained in the ASP. NET page or page. This method is very convenient. You only need a few simple attribute settings to implement the page output Cache Policy. @ Outputcache command DeclarationCodeAs follows.
@ Outputcache command code
Cacheprofile= ""Nost
enhanced in ASP.net 2.0. The page output caching API mainly refers to the HttpCachePolicy class.
using the @ OutputCache directive
With the @ OutputCache directive, you can implement a general need for page output caching. The @ OutputCache directive declares the head of a user control contained in a ASP.net page or page. This approach is very convenient, with just a few simple property settings, you can implement the page's output caching strategy. The @ OutputCache directive declares the f
checked by calling" Select databasepropertyex ('db name', 'isbrokerenabled ')". A '1' means that the broker is enabled. A '0' means that the broker is not enabled. ".
Based on my experience, if a new database is directly created on SqlServer2005, it is enabled by default. If it is imported from other databases, it is disabled by default after the import. (It may be inaccurate. You can test it yourself ). If it has been enabled, it can be directly adjusted to 1.2.2.
1.2.1.1 enable Service Broker
object and automatically cache the page or user control output. Note that the Duration attribute is required. Otherwise, the analyzer error may occur.
Shared
This attribute defines a Boolean value to determine whether the output of a user control can be shared by multiple pages. The default value is false. Note that the @ OutputCache Command included in the ASP. NET page does not support this attribute.
Location
Specifies the location of the output cache. Its Attribute values are OutputCacheLoc
been inherited and enhanced in ASP.net 2.0. The page output caching API mainly refers to the HttpCachePolicy class.
using the @ OutputCache directive
With the @ OutputCache directive, you can implement a general need for page output caching. The @ OutputCache directive declares the head of a user control contained in a ASP.net page or page. This approach is very convenient, with just a few simple property settings, you can implement the page's output caching strategy. The @ OutputCache
during a request:Response.Cache.SetNoStore ();
ProviderName
A string value that identifies the custom output-cache provider to use.
This property is supported only in user controls (. ascx files). It is not supported by the @ OutputCache directive contained in an ASP. NET page (. aspx file).
Shared
A Boolean value that determines whether the user control output can be shared by multiple pages. The default value is False.
of the page to not be cached, so that, while the entire page is cached, the page is processed again when it is requested again, which is not set to the cached content. There are similarities and different aspects of the @ OutputCache directive cached with the OutputCache instruction control cache with the page output. The common denominator is that they are set in the same way, with the @ OutputCache instruction string that contains the properties at the top of the file. The different points in
event of the Default.aspx.vb code, add the following code
Private Sub Page_Load (ByVal sender as Object, ByVal e as System.EventArgs) Handles Me.load
Label1.Text = CType (System.DateTime.Now (), String)
End Sub
Next, we start to configure the Web.config file. We use the following configuration file:
Among them, attention is polltime parameter, polltime parameter is millisecond, the minimum value is 500, the meaning of this parameter sets the system how long to check whether the data in the ca
has been inherited and enhanced in ASP. NET 2.0. The page output caching API mainly refers to the HttpCachePolicy class. Using the @ OutputCache directiveWith the @ OutputCache directive, the general need for page output caching can be achieved. The @ OutputCache directive declares the header of the user control contained in an ASP. NET page or page. This is a convenient way to implement a page's output caching strategy with just a few simple property settings. The @ OutputCache directive decl
HTTP header: by setting the HTTP header in IIS, You can effectively cache images, CSS, JS documents, or other files, but cannot cache data. I have tried this experiment. (Mainly webserver settings), final effect: Content Changes
Outputcache: the page is directly cached on the local computer. Each request only accesses the cache (the time defined by the program that you can use). The final result is that the content will not change.
Use the @ outputcache command
Use the @ outputcache command to
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.