有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: "Mth<%i
ffd yDUzQ
CountBean.java ^vUdf.n9
9!tRM-
/* ."${.BPn~
* CountData.java >354O6
* =4G9ev
4
* Created on 2007年1月1日, 下午4:44 Hc71 .rqS
* DF<_Ns!
* To change this template, choose Tools | Options and locate the template under b1-JnEc
* the Source Creation and Management node. Right-click the template and choose =KkHck33
* Open. You can then make changes to the template in the Source Editor. JVRK\A|R
*/ ws@;2?%A
>#SQDVFf
package com.tot.count; KdUmetx1
mD tD7FzJ
/** k@^)>J^
* VK8 5A
* @author {JMFCc[
*/ E}UlQq
public class CountBean { {A{=RPL
private String countType; 2s~X
int countId; m8.sHw
/** Creates a new instance of CountData */ S~hNSw(-
public CountBean() {} OPar"z^EV
public void setCountType(String countTypes){ %c):^;6p
this.countType=countTypes; .Gw;]s3
} ,u/GA<'#M
public void setCountId(int countIds){ in$Pk$ c
this.countId=countIds; C,.$g>)MZK
} w[t!?(![>
public String getCountType(){ s/8>(-H#
return countType; IWX%6*Zz
} bmFnsqo
public int getCountId(){ mJl|dk_c
return countId; {x
s{
} Zj%l (OVq
} 4 QD.'+L
[;%qxAB/_
CountCache.java $3k5hDA0e
'Tj9btM*cL
/* |}t[-a
* CountCache.java
hT]\*},
* Vv#|%^0
* Created on 2007年1月1日, 下午5:01 zQ&`|kS
* {fmSmD
* To change this template, choose Tools | Options and locate the template under 6x7pqHM
* the Source Creation and Management node. Right-click the template and choose f
0D9Mp
* Open. You can then make changes to the template in the Source Editor. _ 7X0
*/ k%Jv%m}aB
Mt"j< ]EW
package com.tot.count; C;QIp6"1
import java.util.*; 0x*L"HD
/** r&U