有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: zZp0g^;.?
F#-mseKhc
CountBean.java kD;1+lNz
v]{F.N
/* ( f]@lNmx
* CountData.java E.LD1Pm0
* aG_@--=
* Created on 2007年1月1日, 下午4:44 M$YU_RPl+
* Zaime
* To change this template, choose Tools | Options and locate the template under ,=>Ws:j
* the Source Creation and Management node. Right-click the template and choose B!+rO~
* Open. You can then make changes to the template in the Source Editor. ad)jw:n
*/ /]pJ(FFC
hQ7-m.UZw
package com.tot.count; 4*Uzomb?q
4|U$ON?x
/** R.x^
* 00SYNG!
* @author kx{LY`pY
*/ 05>mR qVL
public class CountBean { 5}C.^ J`
private String countType; e'I/}J
int countId; [J!jp&o
/** Creates a new instance of CountData */ ~F"<N q
public CountBean() {} a_Sp}s<J
public void setCountType(String countTypes){ FP=up#zl
this.countType=countTypes; ,ArHS
} Sy@)Q[A
public void setCountId(int countIds){ U1ZKJ<pv
this.countId=countIds; %cO^:
} TW?_fse*[
public String getCountType(){ )d~{gPr.
return countType; 8NnGN(a*D
} z( \4{Y
public int getCountId(){ !\<
[}2}
return countId; !),eEy
} ]J1oY]2~
} q\pI&B
6b2Z}B
CountCache.java |` |#-xu
%?`O
.W
/* q@Aw]Kh
* CountCache.java 6,;dU-A +
* VQ"Z3L3-4
* Created on 2007年1月1日, 下午5:01 !n7'TM'
* CZ33|w
* To change this template, choose Tools | Options and locate the template under "hmLe(jo}
* the Source Creation and Management node. Right-click the template and choose '@/1e\ -y
* Open. You can then make changes to the template in the Source Editor. -1{f(/
*/ 57wHo[CJ
Tbp;xv_qo
package com.tot.count; K'Y/0:"*
import java.util.*; R 7h^
@
/** Ct][B{
* R$ra=sL`
* @author %*zV&H
*/ nR]*RIp5
public class CountCache { .C\2f+(U
public static LinkedList list=new LinkedList(); AQ&vq$
/** Creates a new instance of CountCache */ o:'@|(&