有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Z-Qp9G'
WJOoDS!i
CountBean.java ? +L,
\]V:>=ry>
/* C~B ]@xxK)
* CountData.java r k W7;!
* 4u6 FvN
* Created on 2007年1月1日, 下午4:44 z}ar$}T
* cK+TE8ao
* To change this template, choose Tools | Options and locate the template under Y=P*
* the Source Creation and Management node. Right-click the template and choose P>C'?'Q7
* Open. You can then make changes to the template in the Source Editor. i=aR~
*/ ,2nu*+6Y/
b$,Hlh,^
package com.tot.count; l~rj7f;
}_]AQN$'G
/** e{5?+6KH
* c4Zpt%:}h
* @author TwPQ8}pj?
*/ jr4xh{Z`
public class CountBean { [34N/;5
private String countType; JcR|{9ghT
int countId; xmv%O&0^}
/** Creates a new instance of CountData */ 4GRD- f[
public CountBean() {} HU $"o6ap
public void setCountType(String countTypes){ ;o!p9MEpz;
this.countType=countTypes; CJ\a7=*i
} iYStl
public void setCountId(int countIds){ U =.PL\
this.countId=countIds; G;l7,1;MU:
} v_!6S|
public String getCountType(){ 2h
return countType; MjMDD
} KGy3#r;Q
public int getCountId(){ G%erh}0~
return countId; ,Z@#( =f
} ( 2HM"Pd
} 4k;FZo]S
35& ^spb
CountCache.java a{]=BY oL
\X8b!41
/* vFVUdxPOw
* CountCache.java zFq%[ X
* !4vb{AH
* Created on 2007年1月1日, 下午5:01 fHup&|.
* /|
v.A\:
* To change this template, choose Tools | Options and locate the template under <