有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 7)O?jc
3hab51J
CountBean.java [@U8&W
F8Z<JcOI
/* jy(,^B,]
* CountData.java U2 <*BRJ
* `* "u"7e
* Created on 2007年1月1日, 下午4:44 Yd~K\tX:n
* 25BW/23}e
* To change this template, choose Tools | Options and locate the template under ^_9 ^iL
* the Source Creation and Management node. Right-click the template and choose %P0dY:L~
* Open. You can then make changes to the template in the Source Editor. v Q[{<|K
*/ ~:b bV6YO
DQP#h5O
package com.tot.count; 2!\y0*}K
>&TSz5Q
/** wXPNfV<(2
* \NhCu$'
* @author GK)3a 9;
*/ lyI
rO"o
public class CountBean { k^Zpb&`Hx
private String countType; v]F q}I"
int countId; N~{0QewMI'
/** Creates a new instance of CountData */ ;@Ep?S@
public CountBean() {} z{pNQ[t1Z
public void setCountType(String countTypes){ 4A^hP![c#]
this.countType=countTypes; 7{RI`Er`
} Ev0GAc1
public void setCountId(int countIds){ p^Ca-+R3
this.countId=countIds; EJjTf:
} fKOm\R47
public String getCountType(){ 7Ro7/PT(
return countType; UBOCd[
} OMd{rH
public int getCountId(){ Q-F'-@`(C
return countId; jV\M`=4IC
} Q\z3YUk
} OHssUt
C, n]9
CountCache.java ogs9obbZ!
LTp5T|O
/* <4bv=++pS
* CountCache.java Ictc '#y
* b<