Using caching to improve the performance of ASP applications

Source: Internet
Author: User

In order to improve the performance of ASP program, people often use the data cached in application, but you modify the database how to let application update, this article gives you a reasonable solution.

<%


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 values to application if the data in application is empty value.


', you can change the database when the corresponding application value to empty into the empty, this will be automatically updated when browsing application


' If you update the database (for example, add, modify, or delete data) then remove the corresponding application variable after modifying the database,


' uses the following statement to empty the specified application value, where the Strapp parameter is the application variable name 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: Reading records from a database and using GetRows method


' Saves 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


%>


!--below for an example to illustrate how the above class uses-->


<%


Dim Strapp,strsql,strconn


strapp= "Employee"


strsql= "Select employeeid,titleofcourtesy,firstname,lastname,title,city from Employees"


strconn= "Driver={sql server};server=192.168.0.110;database=northwind;uid=sa;pwd=sa;"


Set Wawa_temp=new wawa_app_getrows


arr_wawa=wawa_temp.wawa_get_list (strapp,strconn,strsql)


%>





<%


Response.Write ("<table width= ' 100% ' border= ' 0 ' cellspacing= ' 1 '")


Dim I,j,rows,flds


Rows=ubound (arr_wawa,2)


Flds=ubound (arr_wawa,1)


If rows>=0 Then


for i=0 to Rows


Response.Write ("<tr>")


for j=0 to Flds


Response.Write "<td>" &amp;arr_wawa (j,i) &amp; "</td>"


Next


Response.Write ("</tr>")


Next


Else


Response.Write ("<tr> <td>" &amp;Rows&amp; "</td> </tr>")


End If


Response.Write ("</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.