有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Ug[0l)
u9 *ic~Nh
CountBean.java 6DEH|2
cri-u E?
/* lBG5~<NT
* CountData.java ,S}wOjb@
* u#ocx[
* Created on 2007年1月1日, 下午4:44 '*U_!RmQ
* _0&U'/cs
* To change this template, choose Tools | Options and locate the template under OK@yMGz1I
* the Source Creation and Management node. Right-click the template and choose 5n::]Q%=D
* Open. You can then make changes to the template in the Source Editor. M6[O>z
*/ V+u0J"/8
8`<3rj
package com.tot.count; bHDZ=Ik
pB VzmQF
/** ASS<XNP
* 80U(q/H%9
* @author Pr/q?qZY
*/ *TL3-S?
public class CountBean { >'3nsR
private String countType; E0A[{UA
int countId; -t*P=V|@
/** Creates a new instance of CountData */ q)"yP\
public CountBean() {} M VE:JNm
public void setCountType(String countTypes){ #E/|WT
this.countType=countTypes; 4SkCV
} 0sq?>$~Kc*
public void setCountId(int countIds){ Z4k'c+
this.countId=countIds; 9:!V":8q
} >(gbUW
public String getCountType(){ B.?@VF
return countType; t4zKI~cO
} PTF|"^k+
public int getCountId(){ [L2N[vy;
return countId; R|\kk?,u
} 9KL)5_6 M
} b\SB
o^d
CountCache.java m7cG]a~a
2N&S__
/* q' t"
* CountCache.java /7R0w
* 9 b&HqkXX
* Created on 2007年1月1日, 下午5:01 PmUq~YZ7
* VkC1\L6
* To change this template, choose Tools | Options and locate the template under gue~aqtJ
* the Source Creation and Management node. Right-click the template and choose A2nL=9~
* Open. You can then make changes to the template in the Source Editor. O2~Q(q'
*/ "6WE6zq
&