有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: :duo#w"K
zSFDUZ]A3
CountBean.java X@f "-\
$ mI0Bk
/* vPD]hs
* CountData.java |M+<m">E
* 'z[Sp~I\
* Created on 2007年1月1日, 下午4:44 SGe^ogO"v
* 3Oi
nK['
* To change this template, choose Tools | Options and locate the template under VhNz8)
* the Source Creation and Management node. Right-click the template and choose Iyyh!MVF
* Open. You can then make changes to the template in the Source Editor. EbdfV-E
*/ TsGE cxIg
}6@pJG
package com.tot.count; (x3.poSt
pbU!dOU~e
/** Q*b]_0Rb
* w.0qp)}
* @author <^lRUw
*/ -k"^o!p
public class CountBean { }|XtypbL
private String countType; Q^#;WASi
int countId; B|&"#Q
/** Creates a new instance of CountData */ EcCFbqS4W
public CountBean() {} 9F*+YG!
public void setCountType(String countTypes){ ETXZ?\<a5
this.countType=countTypes; `3hSLR
} |0%+wB
public void setCountId(int countIds){ X3V'Cy/sy
this.countId=countIds; fF V!)Zj
} OdB?_.+$
public String getCountType(){ f4PIoZ e
return countType; ?'<nx{!c
} G 8V,
public int getCountId(){ `YIf_a{
return countId; Iwc{R8BV
} GPGm]G t
}
4A2?Uhpy
YE9,KVV;$n
CountCache.java dtcIC0:[
pb=cBZ$
/* 7__Q1>o
* CountCache.java 4'LB7}WG
* mD/MJt5
* Created on 2007年1月1日, 下午5:01 7Ddaf>
* FGh]S-A
* To change this template, choose Tools | Options and locate the template under H
`(exa:w
* the Source Creation and Management node. Right-click the template and choose nVI!@qW
* Open. You can then make changes to the template in the Source Editor. E,f>1meN=
*/ p^'3Odd|O
PgRDKygE
package com.tot.count; &