有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: |T!ivd1G
5cY([4,
CountBean.java n."vCP}O+
iKs @oHW
/* AXbDCDA
* CountData.java AP1Eiv<Hub
* -.XICKz
* Created on 2007年1月1日, 下午4:44 J@$h'YUF
* -qv*%O@
* To change this template, choose Tools | Options and locate the template under <0R$yB
* the Source Creation and Management node. Right-click the template and choose -%R3YU3
* Open. You can then make changes to the template in the Source Editor. >/W
*/ PHZ+u@AA6@
{,V .IDs8[
package com.tot.count; %+BiN)R*x
~MuD`a7#G
/** L-J 7z+{
* aNd6#yU$
* @author A5U//y![{
*/ S}QvG&c
public class CountBean { \53(D7+
private String countType; Ph{7S43
int countId; -|Z[GN:
/** Creates a new instance of CountData */ #j!RbW
public CountBean() {} OFc Lh
public void setCountType(String countTypes){ nd~cpHQR^
this.countType=countTypes; zn!H&!8&
} LmCr[9/
public void setCountId(int countIds){ =E E>QM
this.countId=countIds; R<* c
} k9]M=eO
public String getCountType(){ 3W&f^*
return countType; t(d$v_*y51
} g7Xjo )
public int getCountId(){ DcjF$E
return countId; |AgdD
} j%_{tB
} .
#+ N?D<
yHYqJ|t
CountCache.java `;X~$uS
_SVIY@K|/
/* O$
p
* CountCache.java l:' 0
* ,q[aV 6kO
* Created on 2007年1月1日, 下午5:01 \&[Jtv *
* d'bAM{R>
* To change this template, choose Tools | Options and locate the template under 0O@UT1M;v
* the Source Creation and Management node. Right-click the template and choose idG}p+(;
* Open. You can then make changes to the template in the Source Editor. JI"&3H")g%
*/ cD&Q