有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: y/d/#}\:
;(1Xb
CountBean.java ,rZp(moj
"T+oXK\B
/* o1B8_$aYgc
* CountData.java hJsYKd8g
* vD@=V#T
* Created on 2007年1月1日, 下午4:44 L%sskV(
* D<SLv,Y
* To change this template, choose Tools | Options and locate the template under CQGq}.Jt!
* the Source Creation and Management node. Right-click the template and choose Q`* v|Lp
* Open. You can then make changes to the template in the Source Editor. U 4Sxr
*/ b!hs|emo;
{6, l#z
package com.tot.count; ;5TQH_g
/6@~XO)w
/** jXu)%<
* /CW
0N@
* @author d} {d5-_a
*/ !da[#zK
public class CountBean { ']]5xH*U
private String countType; )!tqock*v
int countId; G+dQ" cI9
/** Creates a new instance of CountData */ |MEu"pY)
public CountBean() {} Xe:gH.}
public void setCountType(String countTypes){ n +R3
this.countType=countTypes; tITx+i
} A.@/~\
public void setCountId(int countIds){ yR|Beno
this.countId=countIds; Mb0l*'ZF
} YrRD3P.P
public String getCountType(){ l%^VBv>
2
return countType; 0[SJ7k19
} S]#xG+$<
public int getCountId(){ oMNgyAp^
return countId; +?I1Og
} X_tc\}I]
} F!yr};@^p
t<