有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: j0oto6z~b
vv)O+xt
CountBean.java c1i[1x%
;2`t0#J$]
/* ]qZj@0#7n
* CountData.java +8"8s
* tU Je-3,
* Created on 2007年1月1日, 下午4:44 R-W.$-rF
* ,hJx3g5#n
* To change this template, choose Tools | Options and locate the template under WoNJF6=?
* the Source Creation and Management node. Right-click the template and choose JgHYuLB
* Open. You can then make changes to the template in the Source Editor. 3&E@#I^],
*/ EJz!#f~
.
WJ
package com.tot.count; Q~Nq5[
+B8oW3v# )
/** e\aW~zs 2
* ;B2kot7
* @author rFt+Y})
*/ gkTwGI+w
public class CountBean { pHoxw|'Y
private String countType; ^; U}HAY
int countId; \Js*>xA
/** Creates a new instance of CountData */ Nk%$;Si
public CountBean() {} XmwR^
public void setCountType(String countTypes){ Hr]
this.countType=countTypes; FmF[S&gFRs
} c3rj
:QK6I
public void setCountId(int countIds){ opn6 C )
this.countId=countIds; wNl6a9#
} *'-C/
public String getCountType(){ ;#Qv
)kS*
return countType; bhg6p$411
} 6Rif&W.xy
public int getCountId(){ GU1cMe
return countId; mW[w4J+7P
} IcqzMmb
} @o}J )
<o|k'Y(-
CountCache.java X-bM`7'H
bs%
RWwn
/* FB,rQ9D
* CountCache.java s/>0gu]A8
* ./DlHS;
* Created on 2007年1月1日, 下午5:01 >D##94PZ
* h<'tQGC
* To change this template, choose Tools | Options and locate the template under 1W0[|Hf2v*
* the Source Creation and Management node. Right-click the template and choose ;*nzb!u\\
* Open. You can then make changes to the template in the Source Editor. DH$Nz
*/ K'Wv$[~Dc
Z3Ww@&bU