<%
Class QvodCms_Cache

Public ReloadTime    ' 过期时间（单位为分钟）
Public CacheName     '缓存组的名称
Private CacheData

Private Sub Class_Initialize()
    ReloadTime = Clng(Config(20))
    CacheName = Config(9)
End Sub
'************************************************************
'函数名：SetCache
'作  用：设置缓存对象的值
'参  数：MyCacheName ---- 缓存对象的名称
'        vNewValue ----- 要给缓存对象的值
'返回值：True ---- 设置成功，False ---- 设置失败
'************************************************************
Public Function SetCache(MyCacheName, vNewValue)
    If MyCacheName <> "" Then
        CacheData = Application(CacheName & "_" & MyCacheName)
        If IsArray(CacheData) Then
            CacheData(0) = vNewValue
            CacheData(1) = Now()
        Else
            ReDim CacheData(2)
            CacheData(0) = vNewValue
            CacheData(1) = Now()
        End If
        Application.Lock
        Application(CacheName & "_" & MyCacheName) = CacheData
        Application.UnLock
        SetCache = True
    Else
        SetCache = False
    End If
End Function

'************************************************************
'函数名：GetValue
'作  用：得到缓存对象的值
'参  数：MyCacheName ---- 缓存对象的名称
'返回值：缓存对象的值
'************************************************************
Public Function GetCache(MyChacheName)
    If MyChacheName <> "" Then
        CacheData = Application(CacheName & "_" & MyChacheName)
        If IsArray(CacheData) Then
            GetCache = CacheData(0)
        Else
            GetCache = ""
        End If
    Else
        GetCache = ""
    End If
End Function

'************************************************************
'函数名：ChkCache
'作  用：判断当前缓存是否过期
'参  数：MyCacheName ---- 缓存对象的名称
'返回值：True ---- 已经过期，False ---- 没有过期
'************************************************************
Public Function ChkCache(MyCacheName)
	ChkCache = False
    CacheData = Application(CacheName & "_" & MyCacheName)
    If Not IsArray(CacheData) Then Exit Function
    If Not IsDate(CacheData(1)) Then Exit Function
    If DateDiff("s", CDate(CacheData(1)), Now()) < 60 * ReloadTime Then
        ChkCache = True
    End If
End Function

'************************************************************
'过程名：ClearCache
'作  用：手工删除一个缓存对象
'参  数：MyCacheName ---- 缓存对象的名称
'************************************************************
Public Sub ClearCache(MyCacheName)
    Application.Lock
    Application.Contents.Remove (CacheName & "_" & MyCacheName)
    Application.UnLock
End Sub

'************************************************************
'过程名：ClearAll
'作  用：删除全部缓存对象
'参  数：无
'************************************************************
Public Sub ClearAll()
    Application.Lock()
	Application.Contents.RemoveAll()
	Application.UnLock()
End Sub

End Class
%>