有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: \me5"ZU
XQ~Xls%]
CountBean.java U4*u|A
YE@yts
/* e-*@R#x8+
* CountData.java r 10VFaly
* CHTK.%AQH!
* Created on 2007年1月1日, 下午4:44 n*"r!&Dg
* 1\}XL=BE
* To change this template, choose Tools | Options and locate the template under J4ZHE\
* the Source Creation and Management node. Right-click the template and choose j7)mC4o:%
* Open. You can then make changes to the template in the Source Editor. N!ihj:,
*/ LEM%B??&5z
?98!2:'{9
package com.tot.count; 2d*bF.
X<5fn+{]S:
/** oeg
Bk
* dnomnY(*<
* @author *%/O (ohs@
*/ Xfg3q.q
public class CountBean { t Cb34Wpf
private String countType; tAq0Z)
int countId; T9R#.y,
/** Creates a new instance of CountData */ .K84"Gdx
public CountBean() {} mhVLlbY|t
public void setCountType(String countTypes){ :%&
E58
this.countType=countTypes; .X%J}c$
} EMP|I^
public void setCountId(int countIds){ uD@ZM
this.countId=countIds; FD[*Q2fU
} O*v&CHd3
public String getCountType(){ 6yy%_+k*
return countType; .v(GVkE}
} A:Wr5`FJ
public int getCountId(){ _cvX$(Sg
return countId; /?r A|
} <Q(E {c3"
} Q>D//_TF
8\68NG6o
CountCache.java H?O5 "4a
_{c_z*rM8
/* ?fH1?Z\'K
* CountCache.java O|sk"YXF
* O)`L(
x
* Created on 2007年1月1日, 下午5:01 KANR=G
* hlL$3.]
* To change this template, choose Tools | Options and locate the template under 2$Xof
* the Source Creation and Management node. Right-click the template and choose |l8=z*v<