有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: RGK8'i/X
^1wA:?uN}
CountBean.java r%e KFS
XfKo A0
/* V~
TWKuR
* CountData.java TO-nD>
* ,:%"-`a%
* Created on 2007年1月1日, 下午4:44 )
/v6l
* >y}M.Mm
* To change this template, choose Tools | Options and locate the template under %eJGte-
* the Source Creation and Management node. Right-click the template and choose CT\;xt,S
* Open. You can then make changes to the template in the Source Editor. ]I L;`>Gp
*/ 7^M9qTEHp
/l{&iLz[
package com.tot.count; m~>Y{F2
3
E3qd'
/** _$p$")
* j+^oz'q
* @author N |1>ooU[
*/ OKHX)"j\\
public class CountBean { ^::EikpF%
private String countType; P1 zdK0TM
int countId; ~l$3uN[g
/** Creates a new instance of CountData */ IJJ%$%F/
public CountBean() {} F|&{Rt
public void setCountType(String countTypes){ k2xHH$+{#=
this.countType=countTypes; 9<vWcq*4
} Z lHDi!T
public void setCountId(int countIds){ NWd<+-pC6
this.countId=countIds; Lgz$]Jbl8
} z`Hy'{1
public String getCountType(){ ]7Fs$y.
return countType; !J=sk4T
} zvvP81$W
public int getCountId(){ =0-
$W5E
return countId; (Z}>1WRju
} }@+NN
?P
} 2..,Sk
fA=#Fzk 2
CountCache.java j&