有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 8'?V5.6?|~
MCU{@\?Xf
CountBean.java 9:CJl6~N)#
|i5A
F\w
/* l@nkR&4[
* CountData.java Ok[y3S
* GEXT8f(7
* Created on 2007年1月1日, 下午4:44 P9vN5|"M
* Z3Os9X9p
* To change this template, choose Tools | Options and locate the template under *xXa4HB
* the Source Creation and Management node. Right-click the template and choose mV0F^5
* Open. You can then make changes to the template in the Source Editor. q05_5
*/ b5_(Fv
w}^z1n
package com.tot.count; n.p6+^ES
7. 9n
/** !EuU
@+
* qYc]Y9fi
* @author 7(lR$,bE;=
*/ f
sAgXv
public class CountBean { Ks:~Z9r}
private String countType; /rN%y
int countId; 1iEZ9J?
/** Creates a new instance of CountData */ !1K<iz_8
public CountBean() {} VYI%U'9Q
public void setCountType(String countTypes){ 1$ez}k,
this.countType=countTypes; 48Y5ppcS
} DbFTNoVR
public void setCountId(int countIds){ Z=n#XJO15
this.countId=countIds; IZYq
} \^vf`-uG
public String getCountType(){ O{rgx~lLJt
return countType; [R-4e; SRh
} h.FC:ym"
public int getCountId(){ *IUw$|Z6z)
return countId; o1='Fr
} l;zp f|.Vc
} lg1yj}br
#z 3tSnmp
CountCache.java {@1.2AWg
iX qB-4"
/* aW]!$
* CountCache.java gsd9QW
* aQ mgDF
* Created on 2007年1月1日, 下午5:01 tJo,^fdfv
* &-W5T?Sl
* To change this template, choose Tools | Options and locate the template under G=a.Wff
* the Source Creation and Management node. Right-click the template and choose U.~,Bwb
* Open. You can then make changes to the template in the Source Editor. FCTz>N^p
*/ z.n`0`^
% Uybp
package com.tot.count; gE%{#&