有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: $Z2Y% z6y
btZ9JZvMx
CountBean.java ;I5u"MDHGI
"-U`E)]w*[
/* 2U
Q&n` A
* CountData.java F4|Z:e,Hr
* 5?{ytNCY
* Created on 2007年1月1日, 下午4:44 [G=+f6 a
* "dN4EA&QJ
* To change this template, choose Tools | Options and locate the template under ~t ` uq
* the Source Creation and Management node. Right-click the template and choose [Jjb<6[o
* Open. You can then make changes to the template in the Source Editor. `YinhO:Z
*/ pm 4"Q!K
ff3HR+%M
package com.tot.count; w.2[Xx~
(Q /Kp*a
/** F}C.F
* [|)Eyd[G
* @author
d77->FX2
*/ M'"@l$[QM
public class CountBean { eInx\/
private String countType; M&/([>Q
int countId; NPFrn[M$
/** Creates a new instance of CountData */ />EH]-|
public CountBean() {} X^!1MpEQ
public void setCountType(String countTypes){ XC
D &Im
this.countType=countTypes; :{YOJDtR
} yL#bZ9W
}
public void setCountId(int countIds){ zv%9?:
this.countId=countIds; :4(.S<fH)-
} "kHQ}#6r
public String getCountType(){ 5^}"Tn4I
return countType; NdlJdq
} Z^ e?V7q
public int getCountId(){ n.a55uy
return countId; = DT7]fU
} fF"\$Ny
} aUBGp: (
FuKp`T-H
CountCache.java tsLi5;KA]
YjT7_|`(]
/* (1|_Nr
* CountCache.java xXJl Qbs
* etPb^$
* Created on 2007年1月1日, 下午5:01 )<vU F]e~
* :JEzfI1
* To change this template, choose Tools | Options and locate the template under 'rX!E,59
* the Source Creation and Management node. Right-click the template and choose B}(+\Q$I
* Open. You can then make changes to the template in the Source Editor. S"/M+m+ ]
*/ (eOzntp8
+].Zs<