选择显示字体大小

巧用缓存提高asp程序的性能

<!--为了提高asp程序的性能,人们常常将经常使用的数据缓存在 application,
但是你修改了数据库后怎么让application更新呢,本文给你提供了一个合理的解决办法,
如果谁有更好的算法,请跟帖讨论一下,谢谢
-->
<%
class wawa_app_getrows
public function wawa_get_list(strapp,strconn,strsql)
'********************************
'功能:从application中提取数组,如果application中的数据为empty值的时候再调用wawa_get_rows()函数来给application赋值.
'  ,你可以在修改数据库的时候把相应的application值清空成empty,这就浏览的时候就会自动更新application了
'  如果你更新了数据库(比如说添加,修改或者删除了数据)那么在修改数据库后把相应的application变量去掉,
'  用下面的一条语句来实现清空指定的application值,其中strapp参数是要去掉的application变量名
'  application.contents.remove(strapp)
'  www.knowsky.com
'********************************
dim wawa
wawa = application(strapp)
if isempty(wawa) then
wawa = wawa_get_rows(strconn,strsql)
application(strapp) = wawa
end if
wawa_get_list = wawa
end function

public function wawa_get_rows(strconn,strsql)
'********************************
'功能:从数据库里读取记录并用getrows方法
' 把记录保存成一个数组
'
'********************************
dim rs_wawa
set rs_wawa = createobject("adodb.recordset")
rs_wawa.open strsql,strconn,,1,1
wawa_get_rows = rs_wawa.getrows()
rs_wawa.close
set rs_wawa = nothing
end function
end class
%>
<!-- 下面举个例子来说明上面的那个类怎么使用 -->
<%
dim strapp,strsql,strconn
strapp="xinwendongtai"

strsql="select top 5 id,title from wen where lei=161 order by id desc"
strconn="driver={sql server};server=192.168.0.110;database=new;uid=sa;pwd=sa;"
set wawa_temp=new wawa_app_getrows
arr_xinwendongtai=wawa_temp.wawa_get_list(strapp,strconn,strsql)
%>

<table width="100%" border="0" cellspacing="1">
<% if ubound(arr_xinwendongtai)<>0 then %>
<% for i=0 to ubound(arr_xinwendongtai,2)-1 %>
<tr>
<td><a href="view.asp?id=<%= arr_xinwendongtai(0,i) %>"><%= arr_xinwendongtai(1,i) %></a></td>
</tr>
<% next %>
<% else %>
<tr>
<td>还没有新闻呢</td>
</tr>
<% end if %>
</table>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons