有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 2 I.Q-'@
=4/K#cQ
CountBean.java %u?A>$Jn
P?=}}DI
/* |l~#qeZ%
* CountData.java pSx}:u^am
* P!R`b9_U
* Created on 2007年1月1日, 下午4:44 H/0b3I^
* V4*/t#L/
* To change this template, choose Tools | Options and locate the template under bM,%+9oz;
* the Source Creation and Management node. Right-click the template and choose Z%{`j!!p
* Open. You can then make changes to the template in the Source Editor. }o=s"0 a
*/ 3|Y.+W
UE/iq\a>
package com.tot.count; oJc v D
?,r}@89pY
/** ,_'Z Jlx
* @
&GA0;q0t
* @author RHI?_gf&
*/ y<ZT~e
public class CountBean { 4g+o/+6!4
private String countType; 1mv8[^pF
int countId; /p{$HkVw
/** Creates a new instance of CountData */ \NL*$SnxP
public CountBean() {} T#YJ5Xw
public void setCountType(String countTypes){ F@xKL;'N74
this.countType=countTypes; dsZ-|C
} KctbNMU]k
public void setCountId(int countIds){ 2 o5u02x
this.countId=countIds; `$] ZT>&
} \uOR1z
public String getCountType(){ k~iA'E0-
return countType; jq[Q>"f
} P9gAt4i
public int getCountId(){ d`xDv$QZ
return countId; ;C5
J^xHI
} ](k}B*Abh
} /,9n1|FrG
AR)A <