asp自带的内存缓存 application

来源:asp之家 时间:2011-03-09 11:18:00 

函数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) 

标签:内存缓存,application
0
投稿

猜你喜欢

  • 为你的网页添加背景音乐

    2007-02-03 11:39:00
  • 通过FSO进行页面计数

    2008-11-27 16:02:00
  • 如何把中文转换为UNICODE?

    2009-11-07 18:39:00
  • 从if else到switch case再到抽象

    2010-11-05 18:30:00
  • 搞定web设计中网页路径问题

    2007-09-22 08:52:00
  • JavaScript面向对象的简单介绍

    2008-06-27 12:37:00
  • 讲解Access数据库中数据表的自动重新联接

    2008-11-28 16:29:00
  • 创建数据表/创建列的一些asp函数

    2008-06-24 12:21:00
  • Oracle Index 的三个问题

    2010-07-26 12:53:00
  • SQL Server与Oracle、DB2的优劣对比

    2009-01-07 14:16:00
  • 如何过滤中国站长站(chianz)文章干扰码

    2008-01-04 20:14:00
  • ACCESS 2007出现“错误 '80040e14'“

    2008-06-19 13:21:00
  • MySQL:使用源码分发版还是二进制分发版

    2009-09-01 10:35:00
  • ASP实现下载系统防盗链方法

    2008-02-01 14:05:00
  • 在Win 2003中配置ASP.net环境

    2007-10-14 12:02:00
  • 添加到各大流行网摘 书签的代码

    2008-04-20 14:15:00
  • IE中jscript/javascript的条件编译

    2007-10-03 14:03:00
  • dl.dt.dd.ul.li.ol区别及应用

    2008-05-24 09:42:00
  • 百度在线手写输入法

    2010-02-03 14:27:00
  • 一个比较完美的spacer div技巧

    2009-03-18 19:29:00
  • asp之家 网络编程 m.aspxhome.com