<% Const CACHE_DEFAULT_INTERVAL = 30 ’每隔30秒刷新一次cache Dim HTMLStream Dim IsExpires IsExpires = CacheExpires Function CacheExpires Dim strLastUpdate Dim result strLastUpdate = Application("LastUpdate") If (strLastUpdate = "") Or (CACHE_DEFAULT_INTERVAL < DateDiff("s", strLastUpdate, Now)) Then result = true SetLastUpdateTime Else result = false End If CacheExpires = result End Function
Sub SetLastUpdateTime Application.Lock Application("LastUpdate") = CStr(now()) Application.UnLock End Sub
Sub GetHTMLStream If IsExpires Then UpdateHTMLStream End If HTMLStream=Application("CACHE_HTMLStream") End Sub
Sub UpdateHTMLStream dim d d = FetchHTMLStream Application.Lock Application("CACHE_HTMLStream") = d Application.UnLock End Sub
Function FetchHTMLStream Dim rs ,strSQL, strHTML Set rs = CreateObject("ADODB.Recordset") strSQL = "select categoryID , categoryname from categories" rs.Open strSQL, strConn,adOpenForwardOnly,adLockReadOnly strHTML = strHTML & "" rs.Close Set rs = Nothing FetchHTMLStream = strHTML End Function %>