⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 classcache.asp

📁 依蓝旅游网站管理系统Elan2008.SP2
💻 ASP
字号:
<%
Class ClassCache
   
   Public CacheSn

   Private Sub Class_Initialize()
      CacheSn = "EL.Cache_"
   End Sub
   
   Private Sub Class_Terminate()
   End Sub
   
   Public Function SetCache(ByVal CacheName, ByVal CacheValue, ByVal CacheExpires) 'CacheExpires:有效期,单位分钟  -1为永不过期
      Dim CacheData
	  If CacheName = "" Then
	     SetCache = False
	  Else
	     CacheData = Application(CacheSn & CacheName)
		 If Not IsArray(CacheData) Then
		    ReDim CacheData(2)			
		 End If
		 CacheData(0) = CacheValue
		 CacheData(1) = Now()
		 CacheData(2) = ELClng(CacheExpires)
		 Application.Lock
		 Application(CacheSn & CacheName) = CacheData
		 Application.UnLock
		 SetCache = True
	  End If
   End Function
   
   Public Function GetCache(ByVal CacheName, ByVal GetType)
      Dim CacheData
	  If CacheName = "" Then
	     GetCache = ""
	  Else
	     If CacheTimeout(CacheName) Then
		    Call RemoveCache(CacheName)
		    GetCache = ""
		 Else
		    CacheData = Application(CacheSn & CacheName)
			If IsArray(CacheData) Then
			   Select Case GetType
			      Case 0: GetCache = CacheData(0)
				  Case 1: GetCache = CacheData(1)
				  Case 2: GetCache = CacheData(2)
			   End Select
			Else
			   GetCache = ""
			End If
		 End If	     
	  End If
   End Function
   
   Public Sub RemoveCache(ByVal CacheName)
      Application.Lock
	  Application.Contents.Remove (CacheSn & CacheName)
	  Application.UnLock
   End Sub
   
   Public Sub ClearCache()
      Dim CacheItem, CacheList, i
	  CacheList = ""
	  For Each CacheItem In Application.Contents
	     If CStr(Left(CacheItem, Len(CacheSn))) = CStr(CacheSn) Then
		    CacheList = CacheList &","& CacheItem 
	     End If
	  Next
	  CacheList = Split(CacheList, ",")
	  For i = 1 To UBound(CacheList)
	     Application.Lock
	     Application.Contents.Remove CacheList(i)
	     Application.UnLock
	  Next
   End Sub
   
   Public Sub ClearAllCache()
      Dim CacheItem, CacheList, i
	  CacheList = ""
	  For Each CacheItem In Application.Contents
	     CacheList = CacheList &","& CacheItem 
	  Next
	  CacheList = Split(CacheList, ",")
	  For i = 1 To UBound(CacheList)
	     Application.Lock
	     Application.Contents.Remove CacheList(i)
	     Application.UnLock
	  Next
   End Sub
   
   Public Function CacheTimeout(ByVal CacheName)
      Dim CacheData
	  CacheData = Application(CacheSn & CacheName)
	  If IsArray(CacheData) Then
	     If IsDate(CacheData(1)) Then
		    If ELClng(CacheData(2)) = -1 Then
			   CacheTimeout = False
			Else
		       If DateDiff("s", CDate(CacheData(1)), Now()) < 60 * ELClng(CacheData(2)) Then
			      CacheTimeout = False
			   Else
			      CacheTimeout = True
			   End If
			End If
		 Else
		    CacheTimeout = True
		 End If
	  Else
	     CacheTimeout = True
	  End If
   End Function
   
   Public Function ELClng(ByVal lng)
      If IsNumeric(lng) Then
         ELClng = Clng(lng)
      Else
         ELClng = 0
      End If
   End Function
   
End Class
%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -