'緩存時間,單位分鐘
Const WebCacheTime = 20
'緩存標示,用於一個空間安裝多個系統時使用
Const WebCacheFlag = "Cache"
' 設置緩存 緩存名,緩存值
Function SetCache(ByVal CacheName, ByVal CacheValue)
Dim CacheData
CacheName = LCase(ChangeChr(CacheName))
CacheData = Application(WebCacheFlag & CacheName)
If IsArray(CacheData) Then
CacheData(0) = CacheValue
CacheData(1) = Now()
Else
ReDim CacheData(2)
CacheData(0) = CacheValue
CacheData(1) = Now()
End If
Application.Lock
Application(WebCacheFlag & CacheName) = CacheData
Application.UnLock
End Function
' 獲取緩存 緩存名
Function GetCache(ByVal CacheName)
Dim CacheData
CacheName = LCase(ChangeChr(CacheName))
CacheData = Application(WebCacheFlag & CacheName)
If IsArray(CacheData) Then GetCache = CacheData(0) Else GetCache = ""
End Function
' 檢測緩存 緩存名
Function ChkCache(ByVal CacheName)
Dim CacheData
ChkCache = False
CacheName = LCase(ChangeChr(CacheName))
CacheData = Application(WebCacheFlag & CacheName)
If Not IsArray(CacheData) Then Exit Function
If Not IsDate(CacheData(1)) Then Exit Function
If DateDiff("s", CDate(CacheData(1)), Now()) < 60 * WebCacheTime Then ChkCache = True
End Function