有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Y dmYE$
Uo<d]4p $
CountBean.java \;}F6g
)&<BQIv9/
/* me#VCkr#
* CountData.java kf>oZ*/
* a8FC#kfq
* Created on 2007年1月1日, 下午4:44 6+e@)[l.zc
* dmW0SK
* To change this template, choose Tools | Options and locate the template under YUat}-S
* the Source Creation and Management node. Right-click the template and choose ne4hR]:
* Open. You can then make changes to the template in the Source Editor. I8)x0)Lx
*/ _K3?0<=4
NSUw7hnWvz
package com.tot.count; xg k~y,F
lphQZ{8
/** =U!M,zw4
* \IbGNV`q
* @author dQQh$*IL?{
*/ (2Z-NVU#
public class CountBean { { ,qm=Xjq
private String countType; n:,At]ky
int countId; R~iJ5@[
/** Creates a new instance of CountData */ (\>3FwFHW|
public CountBean() {} (V)nHF*<>
public void setCountType(String countTypes){ /\hybx'
this.countType=countTypes; N2vSJ\u
} kqYWa`eE
public void setCountId(int countIds){ \L-o>O
this.countId=countIds; eYMp@Cx
} /\V-1 7-
public String getCountType(){ (PE x<r1
return countType; $+!/=8R)
} SZW`|ajH
public int getCountId(){ B>WAlmPA
return countId; +1~Y2
} 9`81br+~
} R$IxR=hMx
j
B S$xW
CountCache.java Q\z6/1:9Z
Jw)Uk<