有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: fqY'Uq$=
ZZZ9C#hK^9
CountBean.java b=xn(HE8|
[`qdpzUp&
/* r8eJ&-Yi{Z
* CountData.java X[r0$yuE
* j*gJP
!
* Created on 2007年1月1日, 下午4:44 kE.4 #
* TwI s_r:
* To change this template, choose Tools | Options and locate the template under #=S^i[K/
* the Source Creation and Management node. Right-click the template and choose ;*t#:U*
* Open. You can then make changes to the template in the Source Editor. -y$6gCRY
*/ ls&H oJ7
{QylNC9
package com.tot.count; mB"I(>q*M
{ri={p]l
/** jLt3jN
* LtX53c
* @author e2NK7
*/ v\4<6Z:4
public class CountBean { *9$SFe|&n:
private String countType; .,p=e$x]
int countId; #"rK1Z
/** Creates a new instance of CountData */ ~=iH*AQR
public CountBean() {} zD<W`_z
public void setCountType(String countTypes){ <{bxOr+
this.countType=countTypes; Q2- lHn^L:
} sH;_U)ssH
public void setCountId(int countIds){ 7+hF1eoI
this.countId=countIds; viUJ4Pn
} 1w(3!Ps+
public String getCountType(){ -5 PVWL\
return countType; vg[3\!8z[
} @-Ql6k
public int getCountId(){ -qDqJ62mC
return countId; znTi_S
} 1<73uR&b%
} >8kXa.)84
@WS77d~S
CountCache.java ls:oC},p*
^M6lF5
/* e9RYk:O
* CountCache.java [V:~j1{3
* QwWd"Of
* Created on 2007年1月1日, 下午5:01 p? o[+L<