有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: K?BWl:^x
!w[<?+%%n
CountBean.java P|v ;'9
/SY40;k:
/* -DlKFN
* CountData.java NS#qein~i
* %;!@\5$
* Created on 2007年1月1日, 下午4:44 xp7,0'(;
* [zm&}$nnN
* To change this template, choose Tools | Options and locate the template under %/oOM\}++
* the Source Creation and Management node. Right-click the template and choose t^ Aios~F
* Open. You can then make changes to the template in the Source Editor. Fla[YWS
*/ [@";\C_I
>f^&^28
package com.tot.count; -3qB,KT
J{@gp,&e
/** X;w1@4!
* Sr)/
Mf
* @author ::dLOf8o
*/ =3{h9
public class CountBean { ~4U[p 50
private String countType; b)en/mz
int countId; C:hfI;*7
/** Creates a new instance of CountData */ YUF!Y9!
public CountBean() {} R9o:{U]
public void setCountType(String countTypes){ :u'X
~ID[
this.countType=countTypes; DGC-`z
} ; QR|v
public void setCountId(int countIds){ prlnK
this.countId=countIds; gu/eC
} GuV-[
public String getCountType(){ doFp53NhV
return countType; blid* @-
} 3LG}x/l
public int getCountId(){ 1i_~ZzX8
return countId; N$/{f2iC
} x]euNa
} Eof1sTpA
2K..
;A$
CountCache.java #v:<\-MjN
HLN rI0
/* 29Kuq ;6
* CountCache.java 2
L%d,Ta>
* y`E2IE2o
* Created on 2007年1月1日, 下午5:01 L(PJ9wjkD
* 3hmuF6y~
* To change this template, choose Tools | Options and locate the template under q+~z# jFX
* the Source Creation and Management node. Right-click the template and choose FMwT4]y
* Open. You can then make changes to the template in the Source Editor. &m5