有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ECg/ge2
sTeL4g|%{
CountBean.java \[]36|$LS
;r^8In@6
/* ^z9ITGB~tV
* CountData.java vay_QxB5
* /r[0Dw
* Created on 2007年1月1日, 下午4:44 0RYh4'=F
* L;fhJ~r
* To change this template, choose Tools | Options and locate the template under q^([ & +
* the Source Creation and Management node. Right-click the template and choose sA3 4`ZAa
* Open. You can then make changes to the template in the Source Editor. ~6kEpa
*/ K$#(\-M
RQ9fA1YP
package com.tot.count; mZ7.#R*}
d@7
]=P:
/** #kA/,qyM
* SL pd~ZC?
* @author #XQEfa
*/ Ls5|4%+&
public class CountBean { %:N5k+}
private String countType; #&1mc_`/
int countId; t$]lK6
/** Creates a new instance of CountData */ UXDd8OJL
public CountBean() {} ::9U5E;!
public void setCountType(String countTypes){ k~`pV/6
this.countType=countTypes; 2e/ JFhA
} Jq<&`6hn
public void setCountId(int countIds){ F.c,F R2
this.countId=countIds; }/SbmW8(1
} la</IpC
public String getCountType(){ n0>#?ek12
return countType; ]A5FN4 E
} +]Po!bN@@
public int getCountId(){ }_@*,
return countId; +Z/*=;
} ;R@zf1UYA
} '.c[7zL
Nm\0>}
CountCache.java GXYmJ4wR
;Lu%v%BM
/* aiF7\^aw$
* CountCache.java Y]Vt&*{JV
* vCb3Ra~L`
* Created on 2007年1月1日, 下午5:01 8uP,#D<wZ
* /$|C s
* To change this template, choose Tools | Options and locate the template under FF0N{bY
* the Source Creation and Management node. Right-click the template and choose D\}^<HW
* Open. You can then make changes to the template in the Source Editor. Zz!XH8sH
*/ M56^p,
ylUxK{
package com.tot.count; Nv,1F
import java.util.*; aqQ
YU5l4~
/** -+Axa[,5=
* -y5^xR
* @author }%c2u/PQ
*/ B5GT^DaT
public class CountCache { {pH{SRM)B
public static LinkedList list=new LinkedList(); ,|D_? D)U
/** Creates a new instance of CountCache */ 'Ybd'|t{}
public CountCache() {}
[<