有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: fwvPh&U&
<
H1+qN=]`
CountBean.java d GEMrjx
&+t! LM
/* w.s-T.5.j
* CountData.java ~pM\]OC
* \)H}
* Created on 2007年1月1日, 下午4:44 NpS*]vSO
* V?KACYd@O
* To change this template, choose Tools | Options and locate the template under 8NY$Iw
* the Source Creation and Management node. Right-click the template and choose 9rhIDA(wc
* Open. You can then make changes to the template in the Source Editor. N^,@s"g
*/ w]n ,`r^
%3v:c|r
package com.tot.count; {P'TtlEp
B+e$S%HV
/** u$T`Bn
* Vp3r
* @author |Ld/{&Qr
*/ 6k?,'&z|~
public class CountBean { z}XmRc_Ko
private String countType; <hG=0Zc r
int countId; >:5^4/fo*
/** Creates a new instance of CountData */ Vs>/q:I
public CountBean() {} UsT+o
public void setCountType(String countTypes){ w&6c`az8
this.countType=countTypes; EBF608nWfW
} Koh`|]N
public void setCountId(int countIds){ @8[3]<
this.countId=countIds;
OC0dAxq
} x9fNIuAQ
public String getCountType(){ 1.+w&Y5
return countType; e;LJdd
}
!'-K>.B
public int getCountId(){ NZUQ
R`5
return countId; A0L&p(i
} q2qbbQ6H
} t\[aU\4-7
uXx c2}
CountCache.java " oWiQ{\IP
<28L\pdG`
/* qw]:oh&G
* CountCache.java ,~;_-
* P38D-fLq
* Created on 2007年1月1日, 下午5:01 yc|j]?
* eUiJl6^x
* To change this template, choose Tools | Options and locate the template under Z1V%pg>]*
* the Source Creation and Management node. Right-click the template and choose x --buO
* Open. You can then make changes to the template in the Source Editor. Q~/TqG
U
*/ >s\j/yM
KEfn$\
package com.tot.count; 5o2W[<