有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: +)TOcxF%
`Yc>I!iN
CountBean.java X3rvM8
O.+X,CQG*
/* 04R-}
* CountData.java C?%Oi:Gi&
* 1fb!sbGD.k
* Created on 2007年1月1日, 下午4:44 ,]-A~ ^|
* {siIRl2&
* To change this template, choose Tools | Options and locate the template under C@s;0-qL
* the Source Creation and Management node. Right-click the template and choose *7 >K" j
* Open. You can then make changes to the template in the Source Editor. -AU!c^-o
*/ 9~WjCa*,&
+W9#^
package com.tot.count; L\X2Olfz1
i fbO<
/** &(HIBF'O
* q3R?8Mb
* @author &sJ%ur+G
*/ /|{~GD +A&
public class CountBean { 9`sIE _%+
private String countType; .(2ui~ed
int countId; $qj||zA
/** Creates a new instance of CountData */ !RwOUCk
public CountBean() {} o9uir"=
public void setCountType(String countTypes){ =qVD"Z]z
this.countType=countTypes; ?]u=5gqUU
} ' fP`ET5
public void setCountId(int countIds){ 0CRk&_ht
this.countId=countIds; ~b.e9FhdA
} ZtqN8$[6n
public String getCountType(){ Nb@zn0A(;
return countType; Se-n#
} "#a,R^J
public int getCountId(){ DnW*q/=w
return countId; iu6NIy7D
} $N)b6(}F10
} SV96eYT<
vS'5Lm
CountCache.java ,\n%e'
L5yv}:.U
/* iSxuor^;
* CountCache.java %t\~3pw=
* p8Wik<'^
* Created on 2007年1月1日, 下午5:01 |v%xOl
* +=A53V[C
* To change this template, choose Tools | Options and locate the template under EAM2t|MG.
* the Source Creation and Management node. Right-click the template and choose IQ"9#{o
* Open. You can then make changes to the template in the Source Editor. !o&