有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ?|yJ#j1=
qZ1PC>
CountBean.java Q[tz)99~
RVy 87_J1
/* wb"t:(>&
* CountData.java o;/F=Zp
* 7O :Gi*MA
* Created on 2007年1月1日, 下午4:44 o|E(_Y4d
* me\)JCZpb{
* To change this template, choose Tools | Options and locate the template under k5CIU}H"
* the Source Creation and Management node. Right-click the template and choose W7>_nK+g?
* Open. You can then make changes to the template in the Source Editor. MRu+:Y=K
*/ kIo?<=F8T
$R36`wk
package com.tot.count; T5G+^XDA
5|z[%x~f
/** J1MnkxJmpQ
* ]^%3Y
* @author K2v)"|T)
*/ Yy 1Pipv
public class CountBean { ,aL"Wy(
private String countType; :7*\|2zA
int countId; .1M>KRSr,
/** Creates a new instance of CountData */ -ZJ:<
public CountBean() {} EatDT*!
public void setCountType(String countTypes){ .<hv&t
this.countType=countTypes; LnIJw D
} 1-<Xi-=^{t
public void setCountId(int countIds){
mAKi%)
this.countId=countIds; dq&d>f1
} U {v_0\ES
public String getCountType(){ =B2=UF
return countType; S_=u v)%a
} $E6uA}s
public int getCountId(){ hw2Hn
return countId; ~.tu#Y?
} bN)?szh&Y