有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: PpPg ~ix*
seh1(q?Va4
CountBean.java DBuvbq-
KJPCO0"
/* \$Xo5f<
* CountData.java 12\h| S~
* !Pf_he
* Created on 2007年1月1日, 下午4:44 -iu7/4!j
* ^YddVp
* To change this template, choose Tools | Options and locate the template under A"t~
)
* the Source Creation and Management node. Right-click the template and choose -/:N&6eRb
* Open. You can then make changes to the template in the Source Editor. 8=rD'*
*/ :- B,Q3d
zY\pZG
package com.tot.count; 0FrmZ$
/3F4t
V
/** Az29?|e
* 5?+ECxPt
* @author
NIcPjo
*/ xS%Z
public class CountBean { .lVC>UT
private String countType; jM8e2z3
int countId; i1]*5;q
/** Creates a new instance of CountData */ $Q,Fr;
B
public CountBean() {} \2(Uqf#_
public void setCountType(String countTypes){ `9a %vN
this.countType=countTypes; Fp>iwdjFg
} 6-U+<[,x
public void setCountId(int countIds){ \F;V69'
this.countId=countIds; \_pP:e
} XUT,)dL
public String getCountType(){ Tbl~6P
return countType; aqq7u5O1r
} w=.w*?>
public int getCountId(){ ZUJ!
return countId; t]|WRQvy8
} ig(a28%
} J<h^V+x
<aJdm!6
CountCache.java T4,dhS|
0 1U/{D6D
/* ^&oa\7<'
* CountCache.java \}SA{)
* 8)IpQG
* Created on 2007年1月1日, 下午5:01 Z?k4Kb
* uK6`3lCD
* To change this template, choose Tools | Options and locate the template under xc[LbaBG
* the Source Creation and Management node. Right-click the template and choose pPt7M'uL"
* Open. You can then make changes to the template in the Source Editor. _5'OQ'P2
*/ g4,>cqRkq
OfC0lb:c
package com.tot.count; s&