国产色在线视频-国产色综合一区二区三区-国产身材极品喷水 在线播放-国产深夜福利视频观看-国产深夜福利视频在线-国产深夜福利视频在线播放

ASP比較常用的緩存函數(shù)技巧

2012/10/16 9:34:53   閱讀:3440    發(fā)布者:3440

空間安裝多個系統(tǒng)時使用,ASP比較常用的緩存函數(shù)技巧
Const WebCacheFlag = "Cache"

' 獲取緩存 緩存名
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

' 設置緩存 緩存名,緩存值
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