application服务器缓存--优化JK论坛篇
作者:cmscn 日期:2005-10-18
con_forum_fir.asp中的sub forum_first()函数
是用来论坛版块数据初始化的,读取bbs_forum表中各个版块的设置,一般是不经常变的,所以我们可以利用服务器缓存将这些内容储存起来,从而减少数据库读取次数.方法如下:
引用内容
sub forum_first()
if not application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_true") then
sql="select top 1 forum_id,class_id,forum_f,forum_n,forum_w,forum_star,forum_parent,forum_name,forum_power,forum_type,forum_pro,forum_topic_num,forum_data_num from bbs_forum where forum_id="&forumid&" and forum_hidden=0"
set rs=joekoe_cms.exec(sql,1)
if rs.eof then
rs.close
call format_redirect("forum.asp")
end if
application.lock
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_true")=true
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumf")=rs(2)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumn")=rs(3)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumw")=rs(4)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumstar")=rs(5)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumparent")=rs(6)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumname")=rs(7)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumpower")=rs(8)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumtype")=rs(9)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumpro")=rs(10)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumtopicnum")=rs(11)
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumdatanum")=rs(12)
application.unlock
rs.close
end if
'classid=rs(1)
forumf=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumf")
forumn=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumn")
forumw=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumw")
forumstar=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumstar")
forumparent=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumparent")
forumname=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumname")
forumpower=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumpower")
forumtype=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumtype")
forumpro=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumpro")
forumtopicnum=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumtopicnum")
forumdatanum=application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_forumdatanum")
tit=forumname&"("&ftit&")"
page_power=format_forum_type(forumtype,0,forumpro)
'head_js=head_js&vbcrlf&"var forumid="&forumid&",forumname='"&forumname&"',forumpower='"&forumpower&"';"
end sub
因为是储存在缓存里,所以后台在修改版面设置后,要执行缓存清理,或者在
编辑后加上一句
application(joekoe_cms.web_cookies&"_forum_"&forumid&"_setup_true")=false
前台用户访问时便会重新更新数据.
评论: 7 | 引用: 0 | 查看次数: 900
发表评论