有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: cx|[P6d
j$T2ff6
CountBean.java )~_!u}+:(
WEqHL,Uh]
/* $qD8vu )|j
* CountData.java q?[{fcNh$
* d%1S6eYa'
* Created on 2007年1月1日, 下午4:44 G(JvAe]r
* %83PbH
* To change this template, choose Tools | Options and locate the template under u9:;ft{}N
* the Source Creation and Management node. Right-click the template and choose 'Vy$d<@s[
* Open. You can then make changes to the template in the Source Editor. reM%GU
*/ JnhHV(H
o%h\55 S
package com.tot.count; B5#a
4G.
6ecr]=Cv
/** KZ ?<&x
* TcZ
Ci^1F
* @author 1KruGq~
*/ ?XsL4HIx
public class CountBean { ^wb -s
private String countType; si=/=h
int countId; \>cZ=
/** Creates a new instance of CountData */ 9XT6Gf56
public CountBean() {} `>?\MWyu
public void setCountType(String countTypes){ ]SBv3Q0D7
this.countType=countTypes; 3Aaj+=]W
} MgHyKn'rL
public void setCountId(int countIds){ WaWT
5|A
this.countId=countIds; ]j*o&6cQf
} zVxiCyU
public String getCountType(){ X^_,`H@
return countType; 1k2Ck
} vH#
US
public int getCountId(){ Br]VCp
return countId; X_HR$il
} BRQ9kK20
} :eQ@I+
3, ,Z
CountCache.java ?P<&8eY
)prpG !
/* GK95=?f~8;
* CountCache.java &BG^:4b
* ~#I1!y~`
* Created on 2007年1月1日, 下午5:01 O~{Zs\u9
* 4E4o=Z|K
* To change this template, choose Tools | Options and locate the template under >m}.}g8
* the Source Creation and Management node. Right-click the template and choose 7Yk6C5C
* Open. You can then make changes to the template in the Source Editor. UbC)XiO
*/ X-Xf6&U