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)
'Www.knowsky.com
'********************************
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 ")
Rs_wawa.open strsql, strconn, 1, 1
Wawa_get_rows = rs_wawa.getrows ()
Rs_wawa.close
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 = 192.168.0.110; 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%>
<Tr>
<TD> <a href = "view. asp? Id = <% = arr_xinwendongtai (0, I) %> "> <% = arr_xinwendongtai (1, I) %> </a> </TD>
</Tr>
<% Next %>
<% Else %>
<Tr>
<TD> No news yet </TD>
</Tr>
<% End if %>
</Table>
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.