有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Z6.0X{6nA
h92'~X36
CountBean.java O
WJv<3
U
Bo[iZ|%
/* +pGkeZX
* CountData.java j. @CB`
* ;zMZ+GZ?;+
* Created on 2007年1月1日, 下午4:44 vG`;2laY
* v-(Ry<fT9
* To change this template, choose Tools | Options and locate the template under *bi!iz5F
* the Source Creation and Management node. Right-click the template and choose *.4VO+^
* Open. You can then make changes to the template in the Source Editor. &, =Z
*/ OGDCC/
MF7q*f
package com.tot.count; 5Op|="W.
f!|$!r*q
/** 3Pj#k|(f[0
* 7P&O{tl(
* @author -E*VF{IG1
*/ kOu C@~,
public class CountBean { w=dTa5
private String countType; ,YEwz3$5u
int countId; 2j9+ f{ l
/** Creates a new instance of CountData */ s)gU vS\
public CountBean() {} *0EB{T1
public void setCountType(String countTypes){ 2J>v4EWC
this.countType=countTypes; .(RX;.lw
} <)D)j[
public void setCountId(int countIds){ EAPLe{qw:q
this.countId=countIds; hI+mx
} LSX;|#AI
public String getCountType(){ }^ g6Y3\
return countType; ws^ 7J/8
} !>n^ ;u
public int getCountId(){ i!|OFU6
return countId; E46+B2_~zk
} JO|%Vpco
} !foiGZ3g
DlD;rL=
CountCache.java m2i'$^a#
1FkS$ j8:
/* e-4 Qw#cw
* CountCache.java &bIE"ZBjt
* LqDj4[}
* Created on 2007年1月1日, 下午5:01 W7\s=t\
* ji8)/
* To change this template, choose Tools | Options and locate the template under T>$S&U
* the Source Creation and Management node. Right-click the template and choose ^ UB*Q
* Open. You can then make changes to the template in the Source Editor. &jbZL5
*/ (IE\}QcK
I%8>nMTJ
package com.tot.count; ><l|&&e-
import java.util.*; ;J]Lzh
/** Eku+&