<%
Rem =================================================================
Rem = Class:CacheCls
Rem = Description: Cache application
Rem = Revision:1.01 Beta
Rem = Author: Xiong Hero (cexo255)
Rem = Date:2005/05/6 18:38:10
Rem = QQ:30133499
Rem = MySite:Http://
Rem = Download: Http:///cexo/Cache_pro.rar
Rem = QQ group: 4341998
Rem = Applicable: For some commonly used and unchanged data, the call speed is faster than reading from the database every time.
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(CacheName & "_" & LocalCacheName) = Cache_Data
Else
"There is an error in setting the cache, or the cache name cannot be empty, please update the cache"
()
End If
End Property
Public Property Get Value()
If LocalCacheName<>"" Then
If IsArray(Cache_Data) Then
Value=Cache_Data
End If
Else
"There is an error in setting the cache, or the cache name cannot be empty, please update the cache"
()
End If
End Property
'Get the value in the specified cache
Public Function GetCacheValue(MyCaheName)
GetCacheValue = Application(CacheName & "_" & MyCaheName)
End Function
'Get all cache names
Public Function GetallCacheName()
Dim Cacheobj
For Each Cacheobj in
GetallCacheName = GetallCacheName & Cacheobj & ","
Next
GetallCacheName = Left(GetallCacheName,Len(GetallCacheName)-1)
GetallCacheName = Replace(GetallCacheName,CacheName & "_","")
End Function
'Release the cache
Public Sub DelCahe(MyCaheName)
(CacheName & "_" & MyCaheName)
End Sub
'Release 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
'Statistics the number of times the character Char appears 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 the cache "cexo255" and its value: "cexo2551|cexo2552|cexo2553|cexo2554|cexo2555"
= "cexo255"
= "cexo2551|cexo2552|cexo2553|cexo2554|cexo2555"
'Get the value in the current cache
'CacheArr =
= "wxf"
= "wxf"
= "dw"
= "dw"
'Release cache cexo255
'("cexo255")
'Release all caches
'
'Get the value in cexo255 cache
CacheArr = ("cexo255")
If isArray(CacheArr) Then
For i = 0 to UBound(CacheArr)
CacheArr(i) & "<br>"
Next
Else
"The cache is released!!!"
End if
Set CachePro = Nothing
%>