当前位置: 网学 > 编程文档 > ASP > 正文

CacheCls缓存的应用

来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 13/06/17

网学网为需要asp的朋友们搜集整理了CacheCls缓存的应用相关资料,希望对各位网友有所帮助!

复制代码 代码如下:
<%
Rem =================================================================
Rem = 类:CacheCls
Rem = 说明:缓存的应用
Rem = Revision:1.01 Beta
Rem = 作者:熊氏英雄(cexo255)
Rem = Date:2005/05/6 18:38:10
Rem = QQ:30133499
Rem = MySite:Http://www.Relaxlife.net
Rem = 下载:Http://www.Relaxlife.net/cexo/Cache_pro.rar
Rem = QQ群:4341998
Rem = 适用:对一些常用到,而又不常改变的数据放入缓存中,调用速度要比每次都要从数据库中读要快N陪
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 "设置缓存出错,或缓存名不能为空,请重新更新缓存"
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 "设置缓存出错,或缓存名不能为空,请重新更新缓存"
Response.End()
End If
End Property

''取指定缓存中的值
Public Function GetCacheValue(MyCaheName)
GetCacheValue = Application(CacheName & "_" & MyCaheName)
End Function

''取所有缓存名
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

''释放缓存
Public Sub DelCahe(MyCaheName)
Application.Lock
Application.Contents.Remove(CacheName & "_" & MyCaheName)
Application.unLock
End Sub

''释放所有缓存
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

''统计字符Char在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 = Ne

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号