Let's start by analyzing the code directly. If you do not understand the basic features of the Application object, you can view the object reference section of this site.
<%
The following function is used to present the data update cache from the Dynamic web Forum database. 10 posts in the latest post
function Refreshrecords ()
Dim SQL, Conn, RS
sql = "SELECT top * from Dv_topic ORDER BY dateandtime Desc"
Set conn = Server.CreateObject ("ADODB. Connection ")
Conn. Open "Driver={microsoft Access DRIVER (*.mdb)}; Dbq= "&server.mappath (" Dv.mdb ")
Set rs = Server.CreateObject ("ADODB.") Recordset ")
Rs. Open Sql,conn, 1, 1
If not Rs. EOF Then
Dim Temp
temp= "<ul>"
For I=1 to 10
temp = temp& "<li><a href=" "Http:*/bbs.sfte.net/dispbbs.asp?
Boardid= "&rs" ("Boardid") & "&id=" &rs
("TopicID") & "&page=1" ">" &rs ("Title") & "(" &rs ("Postusername")
& ") </a></li>"
"This place is tastes, obviously with a table,td,tr,tbody to write the front of the people to cooperate, is a very painful thing."
Rs. MoveNext
I=i+1
Next
Temp = temp & "</ul>"
Refreshrecords = Temp
Else
Refreshrecords = "Data call failed."
End If
Rs. Close
Conn. Close
Set rs = Nothing
Set conn = Nothing
End Function
"The following function is used to update the cached
function Displayrecords (secs)
If Application ("cache") = "" Or IsEmpty (Application ("cache") then "" The program updates the cache the first time it is run
"Application" ("cache") is used to save what we need to cache in memory
' Application (' Cache_time ') is used to preserve the time the cache was last updated
"We only need to call the Refresh function in both cases to access the database to update the cache
The first is a server reboot or other unexpected loss of the value of the application store
Application.Lock
Application ("Cache_date") =now ()
' Update cache time
Application ("cache") = Refreshrecords ()
' Update cached content
"' Codeby Niceidea signature
Application.UnLock
End If
If DateDiff ("s", Application ("Cache_date"), now) > secs Then ' compare the difference between the last update time and the current time
The other thing that needs to be updated is cache expiration. A cache is a regular update of a certain amount of data. I'm afraid it's the most common.
Application.Lock
Application ("Cache_date") =now ()
Application ("cache") = Refreshrecords ()
Application.UnLock
End If
Response.Write Application ("cache")
End Function
%>
The last method called is
<%displayrecords (%>)
300 indicates a 5-minute update 60x5=300!