Author: kanyboy www.ASPCool.com Time: 2004-3-22 22:18:05 Views: 1347
Body {font-size: 12px; Font-Family: Verdana, Arial, Song} TD {font-size: 12px; color: # 000000; Font-Family: Verdana, Arial, Song} A: LINK {Color: # 000000; Text-Decoration: None} A: visited {color: # 000000; Text-Decoration: none} a: active {color: # c50000; text-decoration: none} a: hover {color: # c50000; text-decoration: underline } .a {color: #ffffff} .a1 {font-size: 14px; color: # 2c7494} .link_topic {font-size: 18px; text-decoration: none} .formItem {border-right: # 000000 1px solid; Border-top: # 000000 1px solid; font-size: 12pt; border-left: # 000000 1px solid; border-bottom: # 000000 1px solid; background-color: #fffff} ASP.NET Page Cache is a very useful Dongdong, as long as it is simple to add an OutputCache tag on the page, you can let the page directly store the page content output in the cache in the duration, without the need to let the ASP.NET engine execute the page code again. Of course, it is not the most important reason for this execution time, the main reason is that if the page content is removed from the database, then the connection to the database can be used, this advantage is bigger. PageCache is a little small problem, for example, the homepage of many ASP.NET Forum has used PageCache, so the latest post posted in a version does not immediately reflect the home page, but needs to wait for a while. Although it is a bit helpless, this delay is not allowed in some occasions (such as a page that is easy to display item auction status). That is to say, the Cache in ASP.NET cannot automatically change according to the corresponding data in the database, and the corresponding Cache expires, the new SQLCachedependeency feature in ASP.NET 2.0 makes it possible. (Of course, as long as we understand the approximate implementation in ASP.NET 2.0, we can implement this feature based on ASP.NET 1.0, and later I summarize the corresponding method.
To apply SqlCachedependencency features in ASP.NET 2.0, the steps are as follows (based on the Whidbey PDC version in your hand): 1, make the database support SQLCachedependence in the .NET Framework 1.2 installation directory (usually Windows / Microsoft.Net / Framework) /v1.2.30703), there is an ASPNET_REGSQLCACHE.EXE, this command line tool allows our SQLServer 7.0 or SQLServer 2000 to support SQLCachedependencency features, first: "ASPNET_REGSQLCACHE -S server name -u login ID -P password -D database name -ed ", This command allows the specified database to support SQLCACHEPENDENCY, then join the data table to be tracked:" ASPNET_REGSQLCACHE -S server name -u login ID -P password -D database name -t to track the name of the data table, ", This command supports the specified table supports SQLCACHEPENDENCY. What did it do after the scene? First, it has created a table in the specified database called "ASPNET_SQLCACHETABLESFORCHANGENOTIFICATION", this table has three fields, "Tablename" records the name of the data to track, "NotificationCreated" records the time that starts tracking, "ChangeID" is a INT type field, each of the values of this field plus 1 when the data of the tracking data table changes It also adds several stored procedures in the specified database to allow the ASP.NET engine to query the situation of the tracking data sheet. Then, it will add several Trigger to the Table to track, respectively, corresponding to INSERT, UPDATE, DELETE operation, and these Trigger's statement is very simple, that is, the "ASPNET_SQLCACHETABLESFORCHANGENOTIFICATION" table corresponding to "Tablename" field for this tracking The "ChangeID" field of the name of the table is plus one 1. The ASP.NET engine passes the stored procedure "ASPNET_SQLCACACALLINGSTOREDPROCEDURE" by executing it, this stored procedure returns the contents of the "ASPNET_SQLCACHETABLESFORCHANGENOTINET_SQLCACHETABLESFORCHANGENOTINOTIFICATION" table, so that the ASP.NET engine knows which table of data changes. This stored procedure is performed once every 500 milliseconds, but you can modify this interval in Web.config. My experience is that this query is also very resource, huh, huh.
2, web.config is configured in web.config and then simply