有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: *JDQaWzBd
1%68Pnqk
CountBean.java :3J,t//c
9&}$C]`
/* /]zn8d
* CountData.java 'hN_H}U
* :sAb'6u1EU
* Created on 2007年1月1日, 下午4:44 uT:'Kkb!
* >M=_:52.+
* To change this template, choose Tools | Options and locate the template under ul$k xc=N
* the Source Creation and Management node. Right-click the template and choose UKV0xl
* Open. You can then make changes to the template in the Source Editor. ]-h;gN
*/ .R'<v^H
>zFk}/
package com.tot.count; Yl4XgjG
jD1/`g%
/** <ZO"0oz%
* gb+iy$o-
* @author 9.u}<m
*/ :}'5'oVG
public class CountBean { yNCd}
4Ym5
private String countType; BdBwfH%:
int countId; M#%l}
/** Creates a new instance of CountData */ #t
N9#w[K{
public CountBean() {} C+o1.#]JM
public void setCountType(String countTypes){ @h7)M:l
this.countType=countTypes; M3 MB{cA2
} {\zTE1X9
public void setCountId(int countIds){ }z%fQbw
this.countId=countIds; Q*4{2oQ
} *\Z9=8yK
public String getCountType(){ 'u@,,FFz[K
return countType; }C-K0ba7
} o;#:%
public int getCountId(){ 6S K;1Bp-{
return countId; Qw>~]d,Z
} J5dwd,FQ
} )Y4;@pEU
S$#"bK/p^
CountCache.java 0V;9v
6mp8v`b
/* B&