有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: X;
\+<LE
r[`9uVT/
CountBean.java SuJ aL-;
u^+7hkk
/* DZ'P@f)]
* CountData.java {0Yf]FQb-a
* y*jp79G
* Created on 2007年1月1日, 下午4:44 jjB~G^n
* m<T%Rb4?@
* To change this template, choose Tools | Options and locate the template under PB\(=
* the Source Creation and Management node. Right-click the template and choose B[Ku\A6&
* Open. You can then make changes to the template in the Source Editor. )1J R#
*/ n`B:;2X,
Ct <udO
package com.tot.count; H7&8\FNa
FF`T\&u
/** by1<[$8r
* Olt?~}
* @author `_Zg3_K.dS
*/ .nf#c.DI
public class CountBean { M>xK+q?O
private String countType; B:yGS*.tu
int countId; ;s = l52
/** Creates a new instance of CountData */ ok"k*?Ov
public CountBean() {} O'p9u@kc
public void setCountType(String countTypes){ Uou1mZz/
this.countType=countTypes; #?aPisV
X>
} mUAi4N
public void setCountId(int countIds){ a8e6H30Sm
this.countId=countIds; T9E+\D
} Tj`,Z5vy
public String getCountType(){ w,p
PYf/t
return countType; ~]|6T~+]83
} ntX3Nt_n
public int getCountId(){ :\`o8`
return countId; }#RakV4
} ,GhS[VJjR
}
,h m\
X6w6%fzOH>
CountCache.java `iFmrC<
<y('hI'
/* Wq D4YGN
* CountCache.java 2G& a{
* 9rA0lqr]5
* Created on 2007年1月1日, 下午5:01 "+R+6<