<%
'Dim cacheObj 
'Set cacheObj = New AdnCms_Cache
    'cacheObj.SetCache "parsed_index","11111111111111"
    'cacheObj.showAllCache
	'cacheObj.clearAll
	'cacheObj.getCache("parsed_index")
'Set cacheObj = nothing
Class tgzcm_Cache
    '内核:动易级存类
	Public continueTime,vcacheFlag 
	Private v_cacheName,cacheData 
	
	Private Sub Class_Initialize() 
		'continueTime=Clng(tgzcm(20))'缓存过期时间
		continueTime=2'缓存过期时间
		vcacheFlag="tgzcm" '缓存前缀
	End Sub 
	
	Public Function  SetCache(ByVal p_cacheName,ByVal p_cacheValue)'写入缓存
		on error resume next 
		v_cacheName=LCase(p_cacheName) 
		If v_cacheName<>"" Then 
			cacheData=Application(vcacheFlag & v_cacheName) 
			If IsArray(cacheData) Then 
				cacheData(0)=p_cacheValue 
				cacheData(1)=Now()
			Else 
				ReDim cacheData(2) 
				cacheData(0)=p_cacheValue 
				cacheData(1)=Now() 
			End If 
			If err then  
				Set cacheData(0)=p_cacheValue : err.clear 
			end If 
			Application.Lock 
			Application(vcacheFlag & v_cacheName) = cacheData 
			Application.unLock 
		Else 
			die err_cachename
		End If 
	End Function 
	
	Public Function  GetCache(ByVal p_cacheName)'读取缓存
		on error resume next
		v_cacheName=LCase(p_cacheName) 
		If v_cacheName<>"" Then 
			cacheData=Application(vcacheFlag & v_cacheName) 
			If IsArray(cacheData) Then  
				getCache=cacheData(0)
				If err then  
					Set getCache=cacheData(0) : err.clear
				end If
			Else 
				die err_cachevalue 
			End If 
		Else 
			die err_cachename
		End If 
	End Function 
	
	Public Function ChkCache(ByVal p_cacheName) '检查是否存在缓存
		v_cacheName=LCase(p_cacheName)
		chkCache=false 
		cacheData=Application(vcacheFlag & v_cacheName) 
		If Not IsArray(cacheData) Then Exit Function 
		If Not IsDate(cacheData(1)) Then Exit Function 
		If DateDIff("n",CDate(cacheData(1)),Now()) < 60*continueTime Then 
			chkCache=true 
		End If
	End Function 
	
	Public Sub ClearCache(ByVal p_cacheName)'清除缓存 
		v_cacheName=LCase(p_cacheName)
		Application.Lock 
		Application(vcacheFlag & v_cacheName) = Empty 
		Application.unLock 
	End Sub 
	
	Public Function HavedTime(Byval p_cacheName) 
		v_cacheName=LCase(p_cacheName) 
		If v_cacheName<>"" Then 
			cacheData=Application(vcacheFlag & v_cacheName) 
			If IsArray(cacheData) Then 
				havedTime=cacheData(1) 
			Else 
				die err_cachevalue 
			End If 
		Else
			die err_cachename 
		End If 
	End Function
	
	Public Sub ClearAll()'清除所有缓存
		Application.Lock()
		Application.Contents.RemoveAll()
		Application.UnLock()
	End Sub
	
	Public Sub ShowAllCache()'显示所有缓存
		Dim acon
		Response.Write ("缓存对象列表：<br>") 
		For Each acon in Application.Contents
			Response.Write acon&"<br>"
			Response.Flush()
		Next
	End Sub
End Class
%>