有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: EnM }H9A
I "8:IF
CountBean.java 9+z5$
<>|&%gmz
/* ( M > C
* CountData.java A-=B#U F
* ?&ow:OH+
* Created on 2007年1月1日, 下午4:44 .o27uB.
* uTWij4)a
* To change this template, choose Tools | Options and locate the template under *Ce8(
"v,
* the Source Creation and Management node. Right-click the template and choose 2H,^i,
* Open. You can then make changes to the template in the Source Editor. &Zxo\[lP
*/ Sckt gp8
)td?t.4
package com.tot.count; =up!lg^M
8+7n"6GY2/
/** A#b`{C~l
* @Cnn8Y&'
* @author iY|zv|;]=
*/ '7Ad:em
public class CountBean { z<3{.e\e
private String countType; vb&1 S
int countId; yLC5S3^1\"
/** Creates a new instance of CountData */ gv6}GE
public CountBean() {} )s#NQ.T[
public void setCountType(String countTypes){ zL^`r)H
this.countType=countTypes; x|7vN E=Q
} 0xN1Xm0d
public void setCountId(int countIds){ 'aN`z3T
this.countId=countIds; jD<fu
} _,"?R]MO
public String getCountType(){ (plsL
return countType; wt@Qjbqd8
} j O-H1@;
public int getCountId(){ Fm{/&U^
return countId; o+wG69
} x)]_]_vX
} (t.OqgY
z PW [GkD
CountCache.java A89n^@
q2$-U&
/* @5[9iY
* CountCache.java Mnv2tnU]
* ?<*mIf:?
* Created on 2007年1月1日, 下午5:01 lI)RaiMr=
* kPuI'EPK
* To change this template, choose Tools | Options and locate the template under \{GBaMwG~
* the Source Creation and Management node. Right-click the template and choose SU`RHAo
* Open. You can then make changes to the template in the Source Editor. .`ND
*/ P3W<a4 ==
San=E@3}v!
package com.tot.count; Bd8{25{c
import java.util.*; nt5x[xa
/** c; MF
* 0afDqvrC6
* @author ycPGv.6
*/ $:4*?8K2
public class CountCache { &