最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp提高执行效率
时间:2022-07-02 23:18:24 编辑:袖梨 来源:一聚教程网
<%
Function DisplayRecords()
Dim sql, conn, rs
sql = "select [id],[st],[nd] from [table]"
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};DBQ="&Server.MapPath("Database.mdb")
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn,1,3
If Not rs.EOF Then
Dim temp
temp = "
temp = temp & " cellspacing=""2"" cellpadding=""0"">"
temp = temp & "
temp = temp & "
While Not rs.EOF
temp = temp & "
temp = temp & rs("ID") & "
temp = temp & "
temp = temp & "
rs.MoveNext
Wend
temp = temp & ""
DisplayRecords = temp
Else
DisplayRecords = "Data Not Available."
End If
rs.Close
conn.Close
Set rs = Nothing
Set conn = Nothing
End Function
'写入缓存
Function DisplayCachedRecords(Secs)
Dim retVal, datVal, temp1
retVal = Application("cache_demo")
datVal = Application("cache_demo_date")
If datVal = "" Then
datVal = DateAdd("s",Secs,Now)
End If
temp1 = DateDiff("s", Now, datVal)
If temp1 > 0 And retVal <> "" Then
DisplayCachedRecords = retVal
Response.Write "利用缓存读取数据"
Response.Write " ... (" & temp1 & " 秒剩余)"
Response.Write "
"
Else
Dim temp2
temp2 = DisplayRecords()
Application.Lock
Application("cache_demo") = temp2
Application("cache_demo_date") = DateAdd("s",Secs,Now)
Application.UnLock
DisplayCachedRecords = temp2
Response.Write "刷新缓存显示 ..."
Response.Write "
"
End If
End Function
%>
<%
Dim t1, t2
t1 = Timer
Response.Write DisplayCachedRecords(60)
t2 = Timer
%>
停留时间: <%= Left((CDbl((t2 - t1) * 1000.0)), 5) %> ms
相关文章
- 光遇12.23每日任务怎么做 光遇12月23日每日任务做法攻略 12-23
- 光遇12.23大蜡烛在哪里 光遇12月23日大蜡烛位置攻略 12-23
- 光遇12.23免费魔法有什么 光遇12月23日免费魔法收集攻略 12-23
- 《流放之路2》寻找熔炉任务攻略分享 12-23
- 《流放之路2》德雷文打法技巧分享 12-23
- 《流放之路2》永恒裁判者德雷文具体位置介绍 12-23