Clever Use of cache to improve ASP program performance

Source: Internet
Author: User

<! -- To improve ASP Program Performance, people often cache frequently used data in the application,
But how can I update the application after you modify the database? This Article provides you with a reasonable solution. Algorithm Please discuss it with me. Thank you.
Class wawa_app_getrows
Public Function wawa_get_list (Strapp, strconn, strsql)
'Function: extract arrays from the application. If the data in the application is empty, call the wawa_get_rows () function to assign values to the application.
', You can clear the corresponding application value to empty when modifying the database, which will automatically update the application during browsing.
'If you have updated the database (such as adding, modifying, or deleting data), remove the corresponding application variable after modifying the database,
'Use the following statement to clear the specified application value. The Strapp parameter is the name of the application variable to be removed.
'Application. Contents. Remove (Strapp)
Dim Wawa
Wawa = Application (Strapp)
If isempty (Wawa) then
Wawa = wawa_get_rows (strconn, strsql)
Application (Strapp) = Wawa
End if
Wawa_get_list = Wawa
End Function
Public Function wawa_get_rows (strconn, strsql)
'Function: Read records from the database and use the getrows method.
'Save the record as an array
Dim rs_wawa
Set rs_wawa = Createobject ("ADODB. recordset ") strsql, strconn, 1, 1
Wawa_get_rows = rs_wawa.getrows ()
Set rs_wawa = nothing
End Function
End Class
<! -- The following example shows how to use the class above -->
Dim Strapp, strsql, strconn
Strapp = "xinwendongtai"
Strsql = "select top 5 ID, title from wenwhere Lei = 161 order by id desc"
Strconn = "driver = {SQL Server}; server =; database = new; uid = sa; Pwd = sa ;"
Set wawa_temp = new wawa_app_getrows
Arr_xinwendongtai = wawa_temp.wawa_get_list (Strapp, strconn, strsql)
<Table width = "100%" border = "0" cellspacing = "1">
<% If ubound (arr_xinwendongtai) <> 0 then %>
<% For I = 0 to ubound (arr_xinwendongtai, 2)-1%>
<TD> <a href = "view. asp? Id = <% = arr_xinwendongtai (0, I) %> "> <% = arr_xinwendongtai (1, I) %> </a> </TD>
<% Next %>
<% Else %>
<TD> No news yet </TD>
<% End if %>
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: 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.