asp编程中关于application的介绍

来源:爱站网时间:2022-10-24编辑:网友分享
application是一款自带的内存缓存,在asp编程中比较常用于网站读取速度慢的时候,能有效处理缓存问题。接下来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 timeinfo0 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 timeinfo0 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 vipqx1) 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) 

asp编程中关于application的介绍实例代码讲解到这里不知道小伙伴们都看懂了没有,时刻关注爱站技术频道网站,不懂的技术操作可以随时来网站咨询小编。 

上一篇:ASP编程实现自动采集的方法

下一篇:asp要怎么读取xml文件

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载