asp緩衝技術

來源:互聯網
上載者:User

<%
  function readdb()
  Dim objconn,objrs
  set objconn=server.createobject("ADODB.Connection")
  objconn.connectionstring="Provider=Microsoft.Jet.OLEDB.4.0;" &_
                           "Data Source=" & server.mappath("db.mdb")
  objconn.open
  set objrs=server.createobject("ADODB.Recordset")
  objrs.open "admin",objconn,1,2,2
  
  temp=""
  temp=temp&"<div align='center'><center>"
  temp=temp&"<table border='1' cellpadding='0' cellspacing='0' width='300' bordercolor='#0066CC' bordercolorlight='#0066CC' bordercolordark='#0066CC'>"
  temp=temp & "<tr><td bgcolor='#0030CC' align='center' height='26'><font color='#FFFFFF'>ID</font></td>"
  temp=temp & "<td bgcolor='#0030CC' align='center' height='26'><font color='#FFFFFF'>szd_f</font></td>"
  temp=temp & "<td bgcolor='#0030CC' align='center' height='26'><font color='#FFFFFF'>szd_t</font></td></tr>"

  Do while not objrs.Eof

  temp=temp & "<tr><td align='center' height='24'>" & objrs("id") & "</td>"
  temp=temp & "<td align='center' height='24'>" & objrs("szd_f") & "</td>"
  temp=temp & "<td align='center' height='24'>" & objrs("szd_t") & "</td></tr>"

  objrs.movenext
  Loop

  temp=temp & "</table></center></div>"

  readdb=temp
  
  End function



  function readcache(secs)
  Dim temp1,temp2,cachedata,cachedate
  
  cachedata=application("cachedata")
  cachedate=application("cachedate")
  
  if cachedate=Empty then
  cachedate=dateadd("s",secs,now)
  End if
  
  temp1=datediff("s",now,cachedate)

  if temp1>0 and cachedata<>Empty then
  
  temp2=application("cachedata")
  Response.write "<p align='center'><font color='#009933'><b>讀取快取資料,離重新整理時間還有" & temp1 & "秒</b></font></p>"
  
  else
  application.lock
  application("cachedata")=readdb()
  application("cachedate")=dateadd("s",secs,now)
  application.unlock
  temp2=application("cachedata")
  Response.write "<p align='center'><font color='#FF0000'><b>讀取資料庫資料</b></font></p>"
  End if
  
  readcache=temp2

  End function
%>
<html>
asp緩衝技術

<head><title>cachetest</title><style>
<!--
td{font-size:9pt;}
-->
</style>
</head>
<body>
<% Dim starttime,endtime
starttime=timer

Response.write readcache(20)

endtime=timer
Response.write "<p align='center'>頁面已耗用時間為:" & round((endtime-starttime)*1000.0,2) & "ms</p>"
%>
</body>
</html>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.