有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: T9y;OG
~KIDv;HSb[
CountBean.java zxZtz
j,%EW+j$
/* h=RDO
* CountData.java _EYB
8e
* P]<= ! F
* Created on 2007年1月1日, 下午4:44 2C+(":=}
* ;\)=f6N
* To change this template, choose Tools | Options and locate the template under +`| *s3M
* the Source Creation and Management node. Right-click the template and choose ?H;{~n?
* Open. You can then make changes to the template in the Source Editor. jPu5nwvUV>
*/ U
:9=3A2$x
Bmr<O!
package com.tot.count; ]gd/}m)1
@]
.VQ<X|0
/** jD<pIHau
* M?6;|-HH
* @author B1T5f1;uY
*/ Q^h5">P
public class CountBean { Etnb3<^[t
private String countType; m3
IP7h'
int countId; {gkwOMW
/** Creates a new instance of CountData */ ]O{_O&w
public CountBean() {} @5Qoi~o
public void setCountType(String countTypes){ L~0&
Q
this.countType=countTypes; a?<?5
} U}P,EP%p
public void setCountId(int countIds){ 7!d$M{0"
this.countId=countIds; U~QMR-bz
} ?n*fy
public String getCountType(){ (:} <xxl
return countType; ^8742.
} IRB& j%LA
public int getCountId(){ qC
j*>D
return countId; 6VR18Y!y
} G' Hh{_:
} [@.B4p
lP0k:
CountCache.java [
-12]3
c^-YcGwa
/* FGVb@=TO>
* CountCache.java UX}*X`{
* v72,h
* Created on 2007年1月1日, 下午5:01 Qp 69Sk@H{
* AF[>fMI
* To change this template, choose Tools | Options and locate the template under QN #)F
* the Source Creation and Management node. Right-click the template and choose %c0z)R~
* Open. You can then make changes to the template in the Source Editor. 0^iJlR2
*/ *f*f&l