有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: i2;,\FI@t%
a#x@e?GvI
CountBean.java DO9K
f"NWv!
/* SG1AYUs
V
* CountData.java g[uf
e<
* O(9*VoD
* Created on 2007年1月1日, 下午4:44 gjFQDrz(
* ?<5KLvG v
* To change this template, choose Tools | Options and locate the template under
QAMcI:5
* the Source Creation and Management node. Right-click the template and choose 1_]%,
* Open. You can then make changes to the template in the Source Editor. TJ>1?W\Z
*/ baL<|&
c
=P_*.SgR
package com.tot.count; Y^U^yh_!^
om=kA"&&Q
/** tfh`gUV4
* `s3:Vsv4
* @author !&`\MD>;~R
*/ 1'iQlnMO@
public class CountBean { QUfF>,[sv
private String countType; W7@Vma`
int countId; &3xda1H
/** Creates a new instance of CountData */ ?^^TR/
public CountBean() {} `*`ZgTV
public void setCountType(String countTypes){ #l.s>B4
this.countType=countTypes; @v!#_%J
} {x[C\vZsi]
public void setCountId(int countIds){ }_mMQg2>=
this.countId=countIds; o>T+fBHE
} (H:A|Lw
public String getCountType(){ fF=tT C
return countType; ]{#Xcqx
} Y=O-^fL
public int getCountId(){
U z[#ye
return countId; NR-<2
e3
} 2R^Eea
} Fpwhyls
Z!jJ93A"
CountCache.java Ke]'RfO\
,^<39ng
/* %K06owV(S)
* CountCache.java +Jn\`4/J:
* >IA1 \?(
* Created on 2007年1月1日, 下午5:01 @+)T"5_Y[
* Y?zo")
* To change this template, choose Tools | Options and locate the template under <Lt"e8Z> x
* the Source Creation and Management node. Right-click the template and choose a40>_;}:x
* Open. You can then make changes to the template in the Source Editor. ae2SU4Jx
*/ Z:V<