有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 0[Aa2H*
5Px_vtqP
CountBean.java H;E{Fnarv
{eV_+@dT
/* f;a6ux#
* CountData.java K)OlCpHc
* na)ceN2h
* Created on 2007年1月1日, 下午4:44 H\vO0 <X
* wS4wED&a
* To change this template, choose Tools | Options and locate the template under V"73^
* the Source Creation and Management node. Right-click the template and choose ktRdf6:~
* Open. You can then make changes to the template in the Source Editor. Mk;j"ZDF
*/ 9
|Y?#oZ1
[XK"$C]jHJ
package com.tot.count; U>XGJQ<NS
m\=u/Zip
/** [U0c
* V>Cf
8>m
* @author 2rM i~8T
*/ 0M p>X
public class CountBean { ~5b %~:
private String countType; OMU#Sx!6
int countId; uPPe"$
/** Creates a new instance of CountData */ sMK/l @7
public CountBean() {} I(4k{=\ph]
public void setCountType(String countTypes){ zO,sq%vQn'
this.countType=countTypes; Khl7Ez
} 19 _F\32
public void setCountId(int countIds){ ~S9nLb:O{
this.countId=countIds; Jo ^o`9
} (ym)q#^
public String getCountType(){ zoU.\]#C
return countType; M}>q>
} N>_7Ltw/
public int getCountId(){ n_Z8%|h
return countId; P?F:x=@'|
} \?ZdUY
} NKRXY~zHh
7blZAA?-
CountCache.java @?U5t1O<
[Zf<r1m
/* v3p..A~XZ.
* CountCache.java Y'P8 `$
* k1<Py$9"
* Created on 2007年1月1日, 下午5:01 a5iMCmL+
* -'2.^a-8-g
* To change this template, choose Tools | Options and locate the template under #3S/TBy,
* the Source Creation and Management node. Right-click the template and choose y.Py>GJJ1S
* Open. You can then make changes to the template in the Source Editor. {D@y-K5
*/ 4 R]|
_F,OS<>
package com.tot.count; g 0L 4
import java.util.*; ]kPco4
/** gDv]n^&