Frog Frog Recommendation: Skillfully use the cache to improve the performance of ASP program

Source: Internet
Author: User
Programs | caching | Performance <!--Frog Frog Recommendation: Using caching to improve the performance of ASP programs-->
<!--in order to improve the performance of ASP programs, people often use the data cached in application,
But when you modify the database how to let application update, this article provides you with a reasonable solution,
If anyone has a better algorithm, please post a discussion, thank you
-->
<%
Class wawa_app_getrows
Public Function wawa_get_list (strapp,strconn,strsql)
'********************************
' Function: Extract the array from the application, and then call the Wawa_get_rows () function to assign a value to the application if the data in application is a empty value.
' You can empty the corresponding application value into empty when you modify the database, which automatically updates the application when you browse.
' If you update the database (for example, add, modify, or delete the data) then remove the corresponding application variable after modifying the database,
' Use one of the following statements to empty the specified application value, where the Strapp parameter is the application variable name to remove
' 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 the record 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
%>
<!--Here is an example to illustrate how the above class uses-->
<%
Dim strapp,strsql,strconn
strapp= "Xinwendongtai"

Strsql= "SELECT Top 5 id,title from Wen where 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> There's no news yet </td>
</tr>
<% End If%>
</table>



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.