有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: HYmXPpse
tC-KW~&
CountBean.java ~W{h-z%q
v*'\w#
/* [S+-ovl
* CountData.java C/VYu-p%
* *?Ef}:]
* Created on 2007年1月1日, 下午4:44 N)WG~=Gi
* X(28xbd|
* To change this template, choose Tools | Options and locate the template under ;NeEgqW"
* the Source Creation and Management node. Right-click the template and choose MiM=fIuw@s
* Open. You can then make changes to the template in the Source Editor. ][#*h`I
*/ e/jM+%
@$K q<P
package com.tot.count; o{W]mr3D
,s&~U<Z
/** SJ^?D8
* iDc|9"|Tf3
* @author <OSvRWP)
*/ 1[9j`~[([
public class CountBean { CT%m_lN
private String countType; [:@?,?V\N
int countId; $IZZ`Z]B
/** Creates a new instance of CountData */ 6 <S&~q
public CountBean() {} [;YBX]t
public void setCountType(String countTypes){ >I~z7JS
this.countType=countTypes; ^QR'yt3e
} ;o459L>sW
public void setCountId(int countIds){ l{m~d!w`a
this.countId=countIds; Vp"Ug,1
} %ab)Gs
public String getCountType(){ fO!O"D5
return countType; UC/2&7?
} v1g5(
public int getCountId(){ UDtbfc7bk
return countId; \&)W#8V
} #gJ~ {tA:
} lNVAKwW2#
)Hm[j)YI
CountCache.java Er1u1@
NVWeJ+w
/* bMOM`At>z
* CountCache.java |hQ|'VCN
* Sb4PCt
* Created on 2007年1月1日, 下午5:01 \OT)KVwO
* ^6y4!='ci
* To change this template, choose Tools | Options and locate the template under B&