捌度空间 缓存类_ASP教程-查字典教程网
捌度空间 缓存类
捌度空间 缓存类
发布时间:2016-12-29 来源:查字典编辑
摘要:捌度空间缓存类代码复制代码代码如下:

捌度空间缓存类代码

复制代码 代码如下:

<%

classCache

privateobj'cache内容

privateexpireTime'过期时间

privateexpireTimeName'过期时间application名

privatecacheName'cache内容application名

privatepath'url

privatesubclass_initialize()

path=request.servervariables("url")

path=left(path,instrRev(path,"/"))

endsub

privatesubclass_terminate()

endsub

publicpropertygetblEmpty

'是否为空

ifisempty(obj)then

blEmpty=true

else

blEmpty=false

endif

endproperty

publicpropertygetvalid

'是否可用(过期)

ifisempty(obj)ornotisDate(expireTime)then

valid=false

elseifCDate(expireTime)<nowthen

valid=false

else

valid=true

endif

endproperty

publicpropertyletname(str)

'设置cache名

cacheName=str&path

obj=application(cacheName)

expireTimeName=str&"expires"&path

expireTime=application(expireTimeName)

endproperty

publicpropertyletexpires(tm)

'重设置过期时间

expireTime=tm

application.lock

application(expireTimeName)=expireTime

application.unlock

endproperty

publicsubadd(var,expire)

'赋值

ifisempty(var)ornotisDate(expire)then

exitsub

endif

obj=var

expireTime=expire

application.lock

application(cacheName)=obj

application(expireTimeName)=expireTime

application.unlock

endsub

publicpropertygetvalue

'取值

ifisempty(obj)ornotisDate(expireTime)then

value=null

elseifCDate(expireTime)<nowthen

value=null

else

value=obj

endif

endproperty

publicsubmakeEmpty()

'释放application

application.lock

application(cacheName)=empty

application(expireTimeName)=empty

application.unlock

obj=empty

expireTime=empty

endsub

publicfunctionequal(var2)

'比较

iftypename(obj)<>typename(var2)then

equal=false

elseiftypename(obj)="Object"then

ifobjisvar2then

equal=true

else

equal=false

endif

elseiftypename(obj)="Variant()"then

ifjoin(obj,"^")=join(var2,"^")then

equal=true

else

equal=false

endif

else

ifobj=var2then

equal=true

else

equal=false

endif

endif

endfunction

endclass

%>

使用方法:

复制代码 代码如下:

setmyCache=newcache

myCache.name="flash1"

IfmyCache.validthen

StartGet=myCache.value

Else

StartGet=GetHttpPage(HttpUrl)

myCache.addStartGet,dateadd("h",3,Now)

Endif

List=GetBody(StartGet,"</form>","<>",False,False)

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新ASP教程学习
    热门ASP教程学习
    编程开发子分类