手机
当前位置:查字典教程网 >编程开发 >ASP教程 >CacheCls缓存的应用
CacheCls缓存的应用
摘要:复制代码代码如下:0ThenFori=0toUBound(Cachelist)DelCaheCachelist(i)NextEndIfEnd...

复制代码 代码如下:

<%

Rem=================================================================

Rem=类:CacheCls

Rem=说明:缓存的应用

Rem=Revision:1.01Beta

Rem=作者:熊氏英雄(cexo255)

Rem=Date:2005/05/618: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"

ClassCacheCls

PrivateLocalCacheName,Cache_Data

PublicPropertyLetName(ByValvNewValue)

LocalCacheName=LCase(vNewValue)

Cache_Data=Application(CacheName&"_"&LocalCacheName)

EndProperty

PublicPropertyLetValue(ByValvNewValue)

DimN,i,NewValueArr

IfLocalCacheName<>""Then

N=CountInStr(vNewValue,"|")

NewValueArr=Split(vNewValue,"|",-1,1)

ReDimCache_Data(N)

Fori=0toN

Cache_Data(i)=NewValueArr(i)

Next

Application.Lock

Application(CacheName&"_"&LocalCacheName)=Cache_Data

Application.unLock

Else

Response.Write"设置缓存出错,或缓存名不能为空,请重新更新缓存"

Response.End()

EndIf

EndProperty

PublicPropertyGetValue()

IfLocalCacheName<>""Then

IfIsArray(Cache_Data)Then

Value=Cache_Data

EndIf

Else

Response.Write"设置缓存出错,或缓存名不能为空,请重新更新缓存"

Response.End()

EndIf

EndProperty

'取指定缓存中的值

PublicFunctionGetCacheValue(MyCaheName)

GetCacheValue=Application(CacheName&"_"&MyCaheName)

EndFunction

'取所有缓存名

PublicFunctionGetallCacheName()

DimCacheobj

ForEachCacheobjinApplication.Contents

GetallCacheName=GetallCacheName&Cacheobj&","

Next

GetallCacheName=Left(GetallCacheName,Len(GetallCacheName)-1)

GetallCacheName=Replace(GetallCacheName,CacheName&"_","")

EndFunction

'释放缓存

PublicSubDelCahe(MyCaheName)

Application.Lock

Application.Contents.Remove(CacheName&"_"&MyCaheName)

Application.unLock

EndSub

'释放所有缓存

PublicSubRemoveAllCache()

DimCachelist,i

Cachelist=Split(GetallCacheName(),",")

IfUBound(Cachelist)>0Then

Fori=0toUBound(Cachelist)

DelCaheCachelist(i)

Next

EndIf

EndSub

'统计字符Char在Str中出现的次数

PrivateFunctionCountInStr(Str,Char)

CountInStr=0

Dimi,CharLen

CharLen=Len(Char)

Fori=1toLen(Str)

IfMid(Str,i,CharLen)=CharThenCountInStr=CountInStr+1

Next

EndFunction

EndClass

DimCachePro

SetCachePro=NewCacheCls

'设置缓存“cexo255”和它的值:"cexo2551|cexo2552|cexo2553|cexo2554|cexo2555"

CachePro.Name="cexo255"

CachePro.Value="cexo2551|cexo2552|cexo2553|cexo2554|cexo2555"

'取当前缓存中的值

'CacheArr=CachePro.Value

CachePro.Name="wxf"

CachePro.Value="wxf"

CachePro.Name="dw"

CachePro.Value="dw"

'释放缓存cexo255

'CachePro.DelCahe("cexo255")

'释放所有缓存

'CachePro.RemoveAllCache

'取cexo255缓存中的值

CacheArr=CachePro.GetCacheValue("cexo255")

IfisArray(CacheArr)Then

Fori=0toUBound(CacheArr)

Response.WriteCacheArr(i)&"<br>"

Next

Else

Response.Write"缓存被释放!!!"

Endif

SetCachePro=Nothing

%>

【CacheCls缓存的应用】相关文章:

asp截取字符串的两种应用 原创

ASP Request对象的使用

结合asp和存储过程做的搜索程序

用asp实现的数据库中存取文件的代码

asp如何加速网站打开的速度

asp 输入输出的存储过程

asp调用存储过程

ASP调用存储过程的技巧

巧用缓存提高asp程序的性能

asp从缓存读数据实例

精品推荐
分类导航