有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 0v'!(&m
utBKl'`
CountBean.java D@o8Gerq~
YB"=eld
/* O@sJ#i>
* CountData.java (sx,Ol
* n@y*~sG]
* Created on 2007年1月1日, 下午4:44 7aJ:kumDZ
* TV*@h2C"i
* To change this template, choose Tools | Options and locate the template under eTZ2f
* the Source Creation and Management node. Right-click the template and choose QZamf
lk
* Open. You can then make changes to the template in the Source Editor. )UAkg
*/ nsy eid*
)G@/E^ySM
package com.tot.count; L<_zQ
0M|Jvw'n|
/** g0A,VX:2
* m$B)_WW
* @author _/cL"Wf
*/ TtP2>eh-
public class CountBean { W4n(6esO
private String countType; T {zz3@2?
int countId; b0
y*}
/** Creates a new instance of CountData */ HiTj-O
public CountBean() {} SX@zDuM
public void setCountType(String countTypes){ <F-W fR
this.countType=countTypes; #qg(DgH
7
} n
?+dX^j
public void setCountId(int countIds){ Wtqv
this.countId=countIds; |ZJ<N\\h-
} 8 ;o*c6+
public String getCountType(){ [?nM)4d
return countType; DI7g-h8`
} %mMPALN]{
public int getCountId(){ ^ 9 FRI9?
return countId; tW}At
} -VkPy<)
} xoyH5ZK@
to#N>VfD
CountCache.java A7=k9|
(?lKedA>2
/* 2~RG\JWTA
* CountCache.java sH /08Z
* !7jVKI80
* Created on 2007年1月1日, 下午5:01 a474[?
* 4$_:a?9
* To change this template, choose Tools | Options and locate the template under ;eT+Ly|{
* the Source Creation and Management node. Right-click the template and choose m$}Jw<