有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 8A]q!To
$`{q =
CountBean.java 5e8-?w%e
E
:gArQ
/* ;RZa<2
* CountData.java 95&sFT
C
* J
2~B<=V
* Created on 2007年1月1日, 下午4:44 l+X^x%EA
* Sh6 NgO
* To change this template, choose Tools | Options and locate the template under a#GqJ?nY
* the Source Creation and Management node. Right-click the template and choose ?gP/XjToMg
* Open. You can then make changes to the template in the Source Editor. |-Klh
*/ l>P~M50D?{
=|zLr"
package com.tot.count; o@~gg*
}4`YdN
/** TEyPlSGG
* evk
<<zi
* @author }33Au-%*
*/ .%h_W\M<l
public class CountBean { U]&%EqLS
private String countType; -*j;
int countId; BeCr){,3
/** Creates a new instance of CountData */ ]= D
public CountBean() {} *4\ub:9
public void setCountType(String countTypes){ #!j&L6
this.countType=countTypes; sJYX[
} jo:p*Q"F
public void setCountId(int countIds){ 52Ffle8
this.countId=countIds; $}o,7xAn
} r 24]2A
public String getCountType(){ [o6<aE-
return countType; uV\#J{'*
} 3VgH*vAU}
public int getCountId(){ \s rOU|
return countId; uty]-k
} L)"w-,zy
} [vJosbU;
_\]UA?0
CountCache.java cl8Mv
w8zQDPVB%
/* :{i mRa-
* CountCache.java #f@53Pxb
* 9Ky,oB
* Created on 2007年1月1日, 下午5:01 $>`8'I
* :udZfA\sW
* To change this template, choose Tools | Options and locate the template under "q8'tN><