<%
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
Temp = ""
Temp = temp & "<div align = 'center'> <center>"
Temp = temp & "<table border = '1' cellpadding = '0' cellspacing = '0' width = '000000' bordercolor = '# 0066CC' bordercolorlight = '# 0066CC' bordercolordark = '# 0066CC'>"
Temp = temp & "<tr> <td bgcolor = '# 0030CC' align = 'center' height = '26'> <font color = '# ffff'> ID </font> </td>"
Temp = temp & "<td bgcolor = '# 0030CC' align = 'center' height = '26'> <font color = '# ffff'> szd_f </font> </ td>"
Temp = temp & "<td bgcolor = '# 0030CC' align = 'center' height = '26'> <font color = '# ffff'> 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 = '# 000000'> <B> Read cache data, there are still "& temp1 &" seconds </B> </font> </p> "before the refresh time"
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> Read database data </B> </font> </p>"
End if
Readcache = temp2
End function
%>
<Html>
Asp cache technology
<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'> The page runtime is:" & round (endtime-starttime) * 1000.0, 2) & "ms </p>"
%>
</Body>
</Html>