欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

巧用緩存提高asp程序的性能

 更新時間:2006年06月27日 00:00:00   作者:  
<!--為了提高Asp程序的性能,人們常常將經(jīng)常使用的數(shù)據(jù)緩存在 Application,
但是你修改了數(shù)據(jù)庫后怎么讓application更新呢,本文給你提供了一個合理的解決辦法,如果誰有更好的算法,請跟帖討論一下,謝謝
-->
<%
Class wawa_app_getrows
public Function wawa_Get_List(strapp,strconn,strsql)
'********************************
'功能:從Application中提取數(shù)組,如果application中的數(shù)據(jù)為empty值的時候再調(diào)用wawa_Get_Rows()函數(shù)來給application賦值.
' ,你可以在修改數(shù)據(jù)庫的時候把相應(yīng)的application值清空成empty,這就瀏覽的時候就會自動更新application了
' 如果你更新了數(shù)據(jù)庫(比如說添加,修改或者刪除了數(shù)據(jù))那么在修改數(shù)據(jù)庫后把相應(yīng)的application變量去掉,
' 用下面的一條語句來實現(xiàn)清空指定的application值,其中strapp參數(shù)是要去掉的application變量名
' 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)
'********************************
'功能:從數(shù)據(jù)庫里讀取記錄并用getrows方法
' 把記錄保存成一個數(shù)組
'
'********************************
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
%>
<!-- 下面舉個例子來說明上面的那個類怎么使用 -->
<%
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>還沒有新聞呢</td>
</tr>
<% End If %>
</table>

相關(guān)文章

最新評論