Copy Code code as follows:
<%
Rem =================================================================
Rem = class: Cachecls
Rem = Description: Caching applications
Rem = revision:1.01 Beta
Rem = Author: Shong Hero (cexo255)
Rem = Date:2005/05/6 18:38:10
Rem = qq:30133499
Rem = Mysite:http://www.relaxlife.net
Rem = Download: Http://www.Relaxlife.net/cexo/Cache_pro.rar
Rem = QQ Group: 4341998
Rem = applicable: For some commonly used, but infrequently changed data into the cache, call faster than every time to read from the database to be fast n accompany
Rem =================================================================
CacheName = "RL"
Class Cachecls
Private Localcachename, Cache_data
Public Property Let Name (ByVal vnewvalue)
Localcachename = LCase (vnewvalue)
Cache_data=application (CacheName & "_" & Localcachename)
End Property
Public Property Let Value (ByVal vnewvalue)
Dim N,i,newvaluearr
If localcachename<> "" Then
N = Countinstr (Vnewvalue, "|")
Newvaluearr = Split (Vnewvalue, "|", -1,1)
ReDim Cache_data (N)
For i = 0 to N
Cache_data (i) = Newvaluearr (i)
Next
Application.Lock
Application (CacheName & "_" & localcachename) = Cache_data
Application.UnLock
Else
Response.Write "Set cache error, or cache name cannot be empty, please update cache"
Response.End ()
End If
End Property
Public Property Get Value ()
If localcachename<> "" Then
If IsArray (cache_data) Then
Value=cache_data
End If
Else
Response.Write "Set cache error, or cache name cannot be empty, please update cache"
Response.End ()
End If
End Property
' Take the value in the specified cache
Public Function Getcachevalue (mycahename)
Getcachevalue = Application (CacheName & "_" & Mycahename)
End Function
' Take all cache names
Public Function Getallcachename ()
Dim Cacheobj
For each cacheobj in application.contents
Getallcachename = getallcachename & Cacheobj & ","
Next
Getallcachename = Left (Getallcachename,len (getallcachename)-1)
Getallcachename = Replace (Getallcachename,cachename & "_", "")
End Function
' Release cache
Public Sub Delcahe (mycahename)
Application.Lock
Application.Contents.Remove (CacheName & "_" & Mycahename)
Application.UnLock
End Sub
' Free all Caches
Public Sub Removeallcache ()
Dim Cachelist,i
Cachelist=split (Getallcachename (), ",")
If UBound (cachelist) >0 Then
For i=0 to UBound (cachelist)
Delcahe Cachelist (i)
Next
End If
End Sub
' Count the number of occurrences of char chars in str
Private Function countinstr (Str,char)
COUNTINSTR = 0
Dim I, Charlen
Charlen = Len (Char)
For i = 1 to Len (STR)
If Mid (Str, I, charlen) = Char Then countinstr = countinstr + 1
Next
End Function
End Class
Dim Cachepro
Set Cachepro = New cachecls
' Set cache ' cexo255 ' and its value: ' cexo2551|cexo2552|cexo2553|cexo2554|cexo2555 '
Cachepro.name = "cexo255"
Cachepro.value = "cexo2551|cexo2552|cexo2553|cexo2554|cexo2555"
' Take the value in the current cache
' Cachearr = Cachepro.value
Cachepro.name = "WXF"
Cachepro.value = "WXF"
Cachepro.name = "DW"
Cachepro.value = "DW"
' Release Cache cexo255
' Cachepro.delcahe ("cexo255")
' Free all Caches
' Cachepro.removeallcache
' Take the value in the cexo255 cache
Cachearr = Cachepro.getcachevalue ("cexo255")
If IsArray (Cachearr) Then
For i = 0 to UBound (Cachearr)
Response.Write Cachearr (i) & "<br>"
Next
Else
Response.Write "Cache is freed!!! "
End If
Set Cachepro = Nothing
%>