有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: C&0f8PnD
8HLL3H0
CountBean.java T$MXsq
gLt6u|0q
/* E^n!h06~G
* CountData.java ~ a2A"#f
* ]v:,<=S
* Created on 2007年1月1日, 下午4:44 TVvE0y(9
* 'g<{l&u
* To change this template, choose Tools | Options and locate the template under 0aR.ct%
* the Source Creation and Management node. Right-click the template and choose .6[8$8c
* Open. You can then make changes to the template in the Source Editor. .sit5BX
*/ nl2Lqu1
+~F>:v?Rh
package com.tot.count; #"A`:bjG
?@x$ h
/** .mrv"k\<
* 1H">Rb30@
* @author > Q=e9L=
*/ u=@zYA(
public class CountBean { hH>a{7V
private String countType; #QlxEs#%
int countId; T@vE@D
/** Creates a new instance of CountData */ am5;B`}q
public CountBean() {} R7:u 8-dU1
public void setCountType(String countTypes){ i885T'
this.countType=countTypes; &0*l:uw
} )<J #RgE
public void setCountId(int countIds){ p\~ a=
this.countId=countIds; )ty>{t
} h{HpI
0q4
public String getCountType(){ R+0fs$su
return countType; h;E.y
} #('R`~
public int getCountId(){ 8yI4=P"F,
return countId; 6&