当前位置: 首页 > 图文教程 > 网络编程 > ASP > asp自带的内存缓存 application

ASP
简单ASP论坛DIY
如何防止页面中的敏感信息被提取
asp创建对象及中文显示解决技巧
基础开发入门级:JSP与ASP的比较
数据库受到限制怎么办?
ASP初学者常犯的几个错误
Asp定时执行操作、Asp定时读取数据库(网页定时操作详解)
ASP优化:非常实用的ASP提速技巧五则
ASP教程:解决ASP脚本运行超时的方法
ASP安全:简单学习ASP连接数据库方法
简单一招用ASP实现对IE地址栏参数的判断
asp控制xml数据库的6段非常的经典代码
ASP进阶:验证身份证号是否正确的代码
ASP教程:使用ASP生成图片彩色校验码
ASP进阶:用ASP判断文件地址是否有效
ASP进阶:用asp做的简单搜索引擎代码
ASP实例 挂QQ的网页源代码ASP/PHP
ASP答疑 解决ASP脚本运行超时的方法
轻轻松松破解开别人ASP木马密码的方法
用ASP操作Access数据库 ADOX的使用

ASP 中的 asp自带的内存缓存 application


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-01-10   浏览: 136 ::
收藏到网摘: n/a

asp强大的application 是 php 中所没有的。昨天朋友抱怨他的人才网站读取速度慢,于是我帮他把asp中读库比较费时的部分用application做了缓存。 函数getcache,会自动建立需要的缓存。
复制代码 代码如下:

Function getcache(funsname,isreset,isarr,timeinfo)
‘funsname — 需要缓存的内容,这里要输入一个function名
‘isreset –是否更新[值:0(根据时间或判断缓存为空时自动更新)、1(主动更新)]
‘ isarr —- 所缓存的内容是否为一个数据[0为字符串,1为数组]
‘ timeinfo —- 缓存更新时间,单位为秒,当值为0时,则只在缓存为空时,才更新
dim domain = “cnzhaopin.com.cn”
Dim temp_getconfig
Dim re_getcache : re_getcache = False
Dim temp_isarray_type : temp_isarray_type = False
Dim Appfunsname : Appfunsname = Replace(Replace(Replace(funsname,”(”,”"),”)”,”"),”,”,”.”)
If isarr = 1 Then temp_isarray_type = True
If isreset = 1 Then re_getcache = True
If isreset = 2 Then
execute(”temp_getconfig=”&funsname)
getcache = temp_getconfig
Exit Function
End If
If Application(domain&”_”&Appfunsname&”_time”) = “” And timeinfo<>0 Then re_getcache = True
If Not re_getcache Then
If temp_isarray_type Then
If Not IsArray(Application(domain&”_”&Appfunsname)) Then re_getcache = True
Else
If Application(domain&”_”&Appfunsname) = “” Then re_getcache = True
End If
End If
If Not re_getcache And timeinfo<>0 Then
If Int(DateDiff(”s”,Application(domain&”_”&Appfunsname&”_time”),now()))>timeinfo Then re_getcache = True
End If
If re_getcache Then
execute(”temp_getconfig=”&funsname)
Application.Lock
Application(domain&”_”&Appfunsname) = temp_getconfig
Application(domain&”_”&Appfunsname&”_time”) = Now()
Application.UnLock
Else
temp_getconfig=Application(domain&”_”&Appfunsname)
End If
getcache = temp_getconfig
End Function

使用时:
复制代码 代码如下:

Function output3
output3=”"
set newrs=conn.execute(”select TOP 60 companyname,comid,vipdata,ishot from company where isok=1 and vipqx>60 and vipqx<300 and vip=1 and comid in (select comid from jobs where zt<>1) order by newid()”)
do while not newrs.eof
output3=output3 & “……….”
newrs.movenext
loop
newrs.close
set newrs=nothing
End function
response.write getcache(”output3″,0,0,3600)