当前位置: 移动技术网 > IT编程>开发语言>Asp > asp自带的内存缓存 application

asp自带的内存缓存 application

2017年12月12日  | 移动技术网IT编程  | 我要评论
函数getcache,会自动建立需要的缓存。 复制代码 代码如下:function getcache(funsname,isreset,isarr,timeinfo) ‘f
函数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)

如您对本文有疑问或者有任何想说的,请 点击进行留言回复,万千网友为您解惑!

相关文章:

验证码:
移动技术网