有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: O+c@B}[!
*h$Dh5%P
CountBean.java .~C*7_
|VTm5.23
/* f |aO9w
* CountData.java / [:@j+n\
* 7@MVInV9
* Created on 2007年1月1日, 下午4:44 T|r@:t[
*
S+_}=25
* To change this template, choose Tools | Options and locate the template under tOS%.0W5J
* the Source Creation and Management node. Right-click the template and choose X,^J3Ek>O
* Open. You can then make changes to the template in the Source Editor. i3N _wv{
*/ rAk*~OK
fq_ 6xs
package com.tot.count; EcFYP"{U
)k=8.j4
/** [\eUCt F
* "wA3l%d[Y
* @author ,Rz,[KI|
*/ iiKFV>;t/
public class CountBean { (lT
H EiX
private String countType; ME{i-E4
int countId; bvs0y7M='
/** Creates a new instance of CountData */ ,??xW{*|
public CountBean() {} ~cQP4
kBD]
public void setCountType(String countTypes){ i$$\}2m{L
this.countType=countTypes; 7[^:[OEE
} qFt%{~a
S
public void setCountId(int countIds){ }yC ve
this.countId=countIds; n SmYa7
} tk2B\}6
public String getCountType(){ =^O84Cp 6
return countType; 3]M
YHb
} SO3WOR`3
public int getCountId(){ &EV|knW
return countId; *ofK|r
} qqLmjDv
} ok2$ p
'R99kL/.N
CountCache.java s>E4.0[I%
G{$9e}#
/* t&eY+3y,T
* CountCache.java 4f'WF5S/}8
* \^w=T*
* Created on 2007年1月1日, 下午5:01 Ds$FO}KD{
* }|&