有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: T -2t.Xs
e T{ 4{
CountBean.java xC TML!H
RqrdAkg
/* P@B]
* CountData.java x9g#<2w8
* p6@)-2^
* Created on 2007年1月1日, 下午4:44 n\DV3rXI9
* t:Q*gWRh
* To change this template, choose Tools | Options and locate the template under Lq^)R
* the Source Creation and Management node. Right-click the template and choose {\5
* Open. You can then make changes to the template in the Source Editor. f}e`XA?
*/ ZBthU")?
<'*LRd$1
package com.tot.count; ]ieeP4*
;^*W+,4WB
/** AkV#J,
3LC
* eMsd37J
* @author u#.2w)!D
*/ 9A=,E&
public class CountBean { 4HlQ&2O%#
private String countType; IJ"q~r$
int countId; (A#^l=su
/** Creates a new instance of CountData */ VONDc1%ga
public CountBean() {} eauF~md,
public void setCountType(String countTypes){ 0h_|t-9j
this.countType=countTypes; Y3b *a".X
} Yq
KCeg
public void setCountId(int countIds){ %u'ukcL7
this.countId=countIds; 6&x@.1('z
} 0,")C5j
public String getCountType(){ ZE}}W_
return countType; :I#V.
} &QgR*,5eo
public int getCountId(){ }}~ |!8
return countId; C'x&Py/#
} :o3N;*o>)0
} l_p2Riv
L,!?Nt\
CountCache.java GTd,n=
#6=
/* {wKB;?fUvk
* CountCache.java { <