有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: TmG$Cjf84
m]BxGwT=m
CountBean.java KFdTw{GlJ7
5bX
SN$7|
/* /c~z(wv
* CountData.java NyI0[]z
* 9D:p~_"g
* Created on 2007年1月1日, 下午4:44 FyX\S=
* |BnjT*_9
* To change this template, choose Tools | Options and locate the template under xSZgQF~
* the Source Creation and Management node. Right-click the template and choose tT87TmNsA
* Open. You can then make changes to the template in the Source Editor. =vMFCp;mv
*/ cj@Ygc)n
~U#afGH$
package com.tot.count; '5.n28W>
mL`,v
WL/`
/** q'77BRD3
* f8kPbpV,
* @author W}bed],l
*/ D ::),,
public class CountBean { Tw"u{%t
private String countType; I.TdYSB
int countId; N"/jn_>+j
/** Creates a new instance of CountData */ e )l<D)
public CountBean() {} [ ps5;
public void setCountType(String countTypes){ TaeN?jc5
this.countType=countTypes; 5*u0VabC<
} XRCiv
public void setCountId(int countIds){ "l
vPge
this.countId=countIds; DcA{E8Y
} 6lOT5C eJ"
public String getCountType(){ MW8GM }Ho[
return countType; 0gw0
} B}8xA}<
public int getCountId(){ t7tX<|aN
return countId; S/)P&V%
} 2apR7
} fqA\Rp6Z
dO}6zQ\
CountCache.java M_*"g>Z
+<7~yZ[Z8
/* p/L|;c
* CountCache.java >%5Ld`c:SD
* nI.K|hU:P
* Created on 2007年1月1日, 下午5:01 @igr~hJ
* =B@+[b0Z
* To change this template, choose Tools | Options and locate the template under U/9xO"b{.
* the Source Creation and Management node. Right-click the template and choose H)z}6[`
* Open. You can then make changes to the template in the Source Editor. L#mf[a@pCn
*/ @dei}!e
O_}R~p
package com.tot.count; }M-^A{C\%
import java.util.*; ?aOx
b
/** t=o2:p6&
* QG
{KEj2V
* @author F,+nj?i!
*/ `~0)}K.F
public class CountCache { <