有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ou)0tX3j
LCIe1P2
CountBean.java NU.4_cixb
=mwAbh)[7n
/* }#Ji"e
* CountData.java IWddJb~hu
* ~t*_
* Created on 2007年1月1日, 下午4:44 Cvt/ot-J?
* !*qQ7
* To change this template, choose Tools | Options and locate the template under .db:mSrL
* the Source Creation and Management node. Right-click the template and choose ^Kl<<pUaV
* Open. You can then make changes to the template in the Source Editor. r<dvo%I#|
*/ s}gdi
FgP{
package com.tot.count; P|f h4b4
K.? S,qg
/** Y)S
f;
* 5@bmm]
* @author h=au`o&CG
*/ F CfU=4O
public class CountBean { cE,,9M@^
private String countType; 5C-n"8&C&
int countId; +q432ZG
/** Creates a new instance of CountData */ 68qCY
public CountBean() {} ZOJ7^g
public void setCountType(String countTypes){ 1OK~*=/4
this.countType=countTypes; v~!_DD
au
} )Y1+F,C
public void setCountId(int countIds){ ` gor
this.countId=countIds; ))6iVgSE$
} TDR#'i
public String getCountType(){
]>(pQD
return countType; ?,Wm|xY
} %LL?' &&
public int getCountId(){ _(@ezX.p
return countId; 90Z4saSUw
} >6zWOYd
}
OBM&N
2+\@0j[q
CountCache.java 0)|;uW
}Mc&yjhMrg
/* 6bpO#&T
* CountCache.java Ve\!:,(Y_
* g.Kyfs4`
* Created on 2007年1月1日, 下午5:01 !?{%9
* [k,FJ5X
* To change this template, choose Tools | Options and locate the template under /T<,vR
* the Source Creation and Management node. Right-click the template and choose {*qz<U>
* Open. You can then make changes to the template in the Source Editor. _7-P8"m
*/ G:PcV_ihx
Wl>$<D4mO[
package com.tot.count; G8hDR^ra
import java.util.*; vau#?U".}>
/** +&