有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: rBPxGBd4
eQIi}\`
CountBean.java qNVw+U;2P
5j01Mx
A
/* |MrH@v7S
* CountData.java Ntrn("!
* kx(:Z8DX
* Created on 2007年1月1日, 下午4:44 hQxe0Pdt
* b!P;xLcb
* To change this template, choose Tools | Options and locate the template under J+|V[E<x
* the Source Creation and Management node. Right-click the template and choose |OT%,QT|
* Open. You can then make changes to the template in the Source Editor. ;mxT>|z
*/ `IQC\DSl/
_ILOA]ga#
package com.tot.count; SO<K#HfE$?
qr;" K?NX
/** 3AL=*qq
* Q>*K/%KD
* @author gb#wrI
*/ LMzYsXG*[
public class CountBean { J(VZa_
private String countType; AG0x)
int countId; FMr$cKvE]W
/** Creates a new instance of CountData */ P.J}\;S T
public CountBean() {} U}Fk%Jj
public void setCountType(String countTypes){ uCr
this.countType=countTypes; ZSb+92g{L$
} !_#js
public void setCountId(int countIds){ ;9sVWJJCw
this.countId=countIds; )pH{b]t
} >n\Q[W
public String getCountType(){ TI&J>/z;$
return countType; e%>E| 9*u
} rt;>pQ9,
public int getCountId(){ 0zNS;wvv&
return countId; 4Lb<#e13R?
} NFPkK?+
} t!N>0]:mo
39eoL;O_
CountCache.java M$A!
|(g2fByDf
/* u%'22q$
* CountCache.java +y#979A,
* Z28@yD+
* Created on 2007年1月1日, 下午5:01 UG$i5PV%i
* xGPv3TLH^
* To change this template, choose Tools | Options and locate the template under Wd<}|?R
* the Source Creation and Management node. Right-click the template and choose 9V!K._Cb
* Open. You can then make changes to the template in the Source Editor. ,%<77LE
*/ M#|xj <p
_<