有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Rk jKIa
u4,X.3V]A
CountBean.java a$zm/
tZu*Asx7
/* `TD%M`a
* CountData.java h3]@M$Y[
* 7|M $W(P
* Created on 2007年1月1日, 下午4:44 xe gL!
* ?+,*YVT
* To change this template, choose Tools | Options and locate the template under g3~~"`2
* the Source Creation and Management node. Right-click the template and choose Uq]EJu
* Open. You can then make changes to the template in the Source Editor. MHnf\|DX
*/ mj~N]cxB
<% 7P
package com.tot.count; |
2.e0Z]k
L>~@9a\jO
/** n:*_uc^C
* 4)odFq:
* @author `gt&Y-
*/ y@kcXlY
public class CountBean { SGBVR ^
private String countType; !M]%8NTt2
int countId; ?zhI=1ED%
/** Creates a new instance of CountData */ ])QO%
public CountBean() {} qJX+[PJ
public void setCountType(String countTypes){ AFINm%\/0
this.countType=countTypes; ;h,R?mU
} uP(B<NfL:'
public void setCountId(int countIds){ z{`6#
this.countId=countIds; B-\,2rCC Z
} >
h,y\uV1
public String getCountType(){ jiwpDB&