有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: UE0$ o?
x~DLW1I
CountBean.java C"V%# K
[3>GGX[Ic
/* [0;buVU.
* CountData.java /R8p]
* GF<[ }
* Created on 2007年1月1日, 下午4:44 S;\R!%t_
* m@G i6
* To change this template, choose Tools | Options and locate the template under <^R{U&Z@
* the Source Creation and Management node. Right-click the template and choose D{7w!z
* Open. You can then make changes to the template in the Source Editor. DC4C$AyW
r
*/ ^4Uw8-/ 9
|`O5Xs1{B
package com.tot.count; i775:j~zx0
:z"!kzdJ
/** #?O&
* #J\rv'
* @author *|:Q%xr-
*/ #KpY6M-H
public class CountBean { eny/
fm
private String countType; Ve 3 ;
int countId; B;#J"6w
/** Creates a new instance of CountData */ @4+#Xd7"
public CountBean() {} ~Qj}ijWD
public void setCountType(String countTypes){ Y}G_Z#- !
this.countType=countTypes; ~f>2U]F>5
} y0bq;(~X~
public void setCountId(int countIds){ UXr5aZ7y
this.countId=countIds; S6i@"h5
} 8F5|EpB9M
public String getCountType(){ 'xK.UI
return countType; Q(7ob}+jQ
} @E9" Zv-$
public int getCountId(){ 2?7(A
return countId; Tbbz'b;{
} B|=|.qp$)
} U]6&b
&m^@9E)S/
CountCache.java P.\nLE J=
e79KbLV
/* X JGB)3QI
* CountCache.java
^z;JVrW
* Jl<ns,Zg
* Created on 2007年1月1日, 下午5:01 R=)55qu
* wD\ZOn_J
* To change this template, choose Tools | Options and locate the template under f>9s!Hpu_
* the Source Creation and Management node. Right-click the template and choose VDF)zA1V
* Open. You can then make changes to the template in the Source Editor. Bik*b)9y2
*/ *s4\\Wb=
,?cH"@RJ
package com.tot.count; Zl/<