有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Ux~rBv''
_L mDF8Q(
CountBean.java sT"U}
aVI/x5p~
/* zPp?D_t
* CountData.java *]Nd
I
* 7]t$t3I`
* Created on 2007年1月1日, 下午4:44 x |
=
* NPws^
* To change this template, choose Tools | Options and locate the template under -hav/7g
* the Source Creation and Management node. Right-click the template and choose Y_3{\g|x
* Open. You can then make changes to the template in the Source Editor. uFDJRQJ<
*/ %oasIiO
'u }|~u?m
package com.tot.count; ;iJ*.wVq
5CZii=@
/** e"u=4nk
* wu5]S)?*
* @author Pa%;[hbn
*/ &?m|PK) I
public class CountBean { 9NTBdo%u
private String countType; CO e"te
int countId; C%ibIcm y
/** Creates a new instance of CountData */ eRkvNI
public CountBean() {} -~O7.E(ok
public void setCountType(String countTypes){ o}&TFhT
this.countType=countTypes; ?mxBMtc
} .lVC>UT
public void setCountId(int countIds){ jM8e2z3
this.countId=countIds; lwEJ)Bv
} 99%oY
public String getCountType(){ A;nrr1-0
return countType; 5mwtlC':l?
} :kUZNw'Bi
public int getCountId(){ vtyk\e)
return countId; g9>
0N#<
} V)M+dhl
} Q}p+/-U\
TfaL5evio
CountCache.java L>~wcoB
3+mC96wN
/* OOy]:t4 /
* CountCache.java .
:Q[Z
* i3~"qbU%z[
* Created on 2007年1月1日, 下午5:01 [5
Mt,skC:
* hu (h'
* To change this template, choose Tools | Options and locate the template under bD_|n!3
* the Source Creation and Management node. Right-click the template and choose TwBwqQ)t
* Open. You can then make changes to the template in the Source Editor. b/IT8Cm3
*/ E/mp.f2!
.LDK+c
package com.tot.count; tbHU(#~
import java.util.*; ~1xln?Q
/** _-aQ.p ?T
* +}H2|vP
* @author lub(chCE[
*/ }%_h|N
public class CountCache { R I Bj9kd
public static LinkedList list=new LinkedList(); OfC0lb:c
/** Creates a new instance of CountCache */ s&