有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: nWk e#{[
19p8B&
CountBean.java uxb:^d?D!
:5jexz."M
/* B X*69
* CountData.java zd.'*Dj
* `kFiH*5 %z
* Created on 2007年1月1日, 下午4:44 r_^)1w
* Tpb"uBiXoo
* To change this template, choose Tools | Options and locate the template under E~qQai=]
* the Source Creation and Management node. Right-click the template and choose grspt}
* Open. You can then make changes to the template in the Source Editor. t{zBC?cR
*/ *jE;9^
h48YDWwy
package com.tot.count; h,t:]
P3!Atnv2
/** q6REh;$
* CcY7$D
* @author NO2(vE
*/ 6T_K9
public class CountBean { 6Cv.5Vhx
private String countType; IB8gDP2
int countId; T cJ$[
/** Creates a new instance of CountData */ &qKigkLd
public CountBean() {} RU|X*3";T
public void setCountType(String countTypes){ i'=2Y9S}
this.countType=countTypes; ,:UX<6l
R
} q_sEw~~@!
public void setCountId(int countIds){ %m`zWg-
this.countId=countIds; lI6W$V\,
} &n>7Ir
public String getCountType(){ L=]p_2+
return countType; rEM#D]k
} at|
\FOKj
public int getCountId(){ t"|DWC*
return countId; [1SMg$@<
} |cgui
} cS(;Qs]Q
G>K@AW#
CountCache.java 0e16Ow6\!1
DW>ES/B8$(
/* [EOVw%R
* CountCache.java @PX\{6&
* 2"X~ju
* Created on 2007年1月1日, 下午5:01 &I/qG`W
* 2.nE
k
* To change this template, choose Tools | Options and locate the template under <