有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ,fhK
3WPZZN<K9
CountBean.java y`pgJO
{7EpljH@
/* w%%*3[--X
* CountData.java J #;|P-pt
* H9[0-Ur5
* Created on 2007年1月1日, 下午4:44 w|-m*v
.
* 4@Bl 1b[<
* To change this template, choose Tools | Options and locate the template under 12}!oS~_
* the Source Creation and Management node. Right-click the template and choose j!IkU}*c
* Open. You can then make changes to the template in the Source Editor. &HqBlRo
*/ f/sLQdK,
-E.fo._L5
package com.tot.count; Rvd'uIJ
(:RYd6i
/** 3O|2Z~>3
* Bsj^R\
* @author QGnUPiD^
*/ VP1z"j:
public class CountBean { Dp?lgw
private String countType; M'@
int countId; 4!-/m7%eF
/** Creates a new instance of CountData */ ah#jvp
public CountBean() {} @/='BVb'T
public void setCountType(String countTypes){ BoHNni
this.countType=countTypes; [*r=u[67F
} ?JR?PW8
public void setCountId(int countIds){ <_SdW 5BF<
this.countId=countIds; <lRjh7
} )~ ^`[`
public String getCountType(){ GGsAisF"N
return countType; MKX58y{+
}
4G j
public int getCountId(){ `X(H,Q}*;
return countId; )c<[@::i
} QvlVjDIy
} yL23Nqe
j/1f|x
CountCache.java Z5@E|O &
mJsU7bD`
/* 12l1u[TlS
* CountCache.java |)[&V3+|
* R?#.z#
* Created on 2007年1月1日, 下午5:01 UTO$L|K
* r<