有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: b=<xzvy
nzI}w7>VU
CountBean.java XKqUbi
o<T_Pjp
/* 4OLq
* CountData.java QF 2Eg
* jFYv4!\ju
* Created on 2007年1月1日, 下午4:44 /I@nPH<y
* @&!HMl
* To change this template, choose Tools | Options and locate the template under ,<]X0;~oB
* the Source Creation and Management node. Right-click the template and choose {bB;TO<b`
* Open. You can then make changes to the template in the Source Editor. lTOO`g
*/ 4#H~g
@
m:@-]U@6
package com.tot.count; T^9k,J(rM
@m14x}H
/** SenDJv00
* 8':^tMd
* @author M5DW!^
*/ F6 ?4E"d
public class CountBean { ,#Y>nP0
private String countType; 595P04
int countId; ?ysC7((
/** Creates a new instance of CountData */ KrNu7/H
public CountBean() {} (vHB`@x
public void setCountType(String countTypes){ ;<qv-$P
this.countType=countTypes; RM2<%$
} PS ,@ \
public void setCountId(int countIds){ G|5M~zP
this.countId=countIds; p]z
*
} ZujPk-
public String getCountType(){ P)he3
return countType; CFqteY"
}
)L}6to
public int getCountId(){ 9Tbi_6[
return countId; 6BT o%
} ;Js-27_0
} fg1_D
-ZXC^zt
CountCache.java x O`#a=
UR;FW`
/* 'Q\I@s }
* CountCache.java mouLjT&p
* pUV3n
1{2
* Created on 2007年1月1日, 下午5:01 ~Xa8\>
* "W:#4@
F
* To change this template, choose Tools | Options and locate the template under bnS"@^M
* the Source Creation and Management node. Right-click the template and choose e)I-|Q4^%
* Open. You can then make changes to the template in the Source Editor. $J8?!Xg
*/ go^?F-
dZ
IyvJwrO
package com.tot.count; Na8%TT>
import java.util.*;
[0v`E5
/** /Q
Xq<NG
* vvEr}G
* @author w-9FF%@<
*/ gc|?$aE
public class CountCache { 4Eq$f (QJ
public static LinkedList list=new LinkedList(); ^(5Up=.EA
/** Creates a new instance of CountCache */ "P O>@tY
public CountCache() {} P[NAO>&t