有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: {;(g[H=q;
OTtanJ?
CountBean.java !k??Kj
x8rFMR#S=
/* X#NeB>~
* CountData.java }AH|~3|D
* )]>Y*<s }
* Created on 2007年1月1日, 下午4:44 %_J/&{6G
* YT%SCaU
* To change this template, choose Tools | Options and locate the template under ^N}~U5
* the Source Creation and Management node. Right-click the template and choose <+1w'-
* Open. You can then make changes to the template in the Source Editor. ZD] '$
*/ q$2taG}
!L.z4n,n+
package com.tot.count; H1ui#5n2
[\%t<aa
/** b>AAx$2Y
* <~8f0+"
* @author \#oV<MR
*/ rM~IF+f0XD
public class CountBean { wqoN@d
private String countType; I:>d@e/;
int countId; ]O(HZD%
/** Creates a new instance of CountData */ S?z j&XY3
public CountBean() {} VA
r?teY
public void setCountType(String countTypes){ uKAHJ$%
this.countType=countTypes; _G8y9!J
} WxP4{T* <
public void setCountId(int countIds){ $6?KH7lA
this.countId=countIds; m4.V$U,H]
} #FDu4xi
public String getCountType(){ 1sJJ"dC.w
return countType; ?(L?X&)v
} {Ll8@'5
public int getCountId(){ x)sDf!d4bi
return countId; $bC!T
} W:( Usy
} :7;Iy u
p{#7\+}
CountCache.java d_|v=^;
]{,=mOk
/* P>,D$-3
* CountCache.java 4a-F4j'
* e5\1k#@
* Created on 2007年1月1日, 下午5:01 KNyD}1
* S5 oHe4#89
* To change this template, choose Tools | Options and locate the template under GKDG5u;
* the Source Creation and Management node. Right-click the template and choose op{(mn
* Open. You can then make changes to the template in the Source Editor. 0QSi\: 1f
*/ gwjv&.T6^
)Zr0_b"V:e
package com.tot.count; RX|&