一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

asp缓存技术

时间:2008-04-22 编辑:简简单单 来源:一聚教程网

<%
  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&"

"
  temp=temp&""
  temp=temp & ""
  temp=temp & ""
  temp=temp & ""

  Do while not objrs.Eof

  temp=temp & ""
  temp=temp & ""
  temp=temp & ""

  objrs.movenext
  Loop

  temp=temp & "
IDszd_fszd_t
" & objrs("id") & "" & objrs("szd_f") & "" & objrs("szd_t") & "
"

  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 "

读取缓存数据,离刷新时间还有" & temp1 & "秒

"
  
  else
  application.lock
  application("cachedata")=readdb()
  application("cachedate")=dateadd("s",secs,now)
  application.unlock
  temp2=application("cachedata")
  Response.write "

读取数据库数据

"
  End if
  
  readcache=temp2

  End function
%>

asp缓存技术

cachetest


<% Dim starttime,endtime
starttime=timer

Response.write readcache(20)

endtime=timer
Response.write "

页面运行时间为:" & round((endtime-starttime)*1000.0,2) & "ms

"
%>

热门栏目