有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: !G~`5?CvE
~Zo;LSI
CountBean.java @JU
Xp
prO ~g
/* IUSV\X9
* CountData.java rhj_cw
* N%fDgK
* Created on 2007年1月1日, 下午4:44 9/$Cq
* VkZ3 Q7d
* To change this template, choose Tools | Options and locate the template under re@;6o
* the Source Creation and Management node. Right-click the template and choose EN;4EC7tE
* Open. You can then make changes to the template in the Source Editor. "eZ~]m}L0
*/ UB3hC`N\
\CVrLn;}
package com.tot.count; cs0rz= ZdH
\<Di|X1
/** p%ZAVd*|#V
* N.dcQQ_iS
* @author RLR\*dL1
*/ !T
RU
public class CountBean { y[d>7fcf
private String countType; :@K~>^+U
int countId; $_Q]3"U
/** Creates a new instance of CountData */ Fb<fQIa
public CountBean() {} gRg8D{
public void setCountType(String countTypes){ Q1[EiM3
this.countType=countTypes; Ob@HzXH
} &*9' 0
public void setCountId(int countIds){ JV@b(x`
this.countId=countIds; bD<hzOa
} H-jxH,mJmW
public String getCountType(){ (Ky$(Ubb#6
return countType; .'zcD^
}
,)Z1&J?
public int getCountId(){ *Z2#U?_
return countId; #@}wl
} \vF*n Z5/
} kWbD?i-
)W |_f
CountCache.java g![?P"i^t
Hl=M{)q@
/* 'W*ODAz6
* CountCache.java ~As_O6JI
* ,QPo%{:p
* Created on 2007年1月1日, 下午5:01 w<Ot0&