有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ZS(%!+ M
} eHxw+.
CountBean.java o 7tUv"Rs
<rK[ &JlJ
/* 4'*.3f'bp
* CountData.java _xm<zy{`S
* BN%cX2j
* Created on 2007年1月1日, 下午4:44 %*npLDi
* Z}\,rex
* To change this template, choose Tools | Options and locate the template under 6S_mfWsi
* the Source Creation and Management node. Right-click the template and choose 3c,4 wyn
* Open. You can then make changes to the template in the Source Editor. Q3&DA1b`
*/ 39
zfbxX
U!uJ )mm
package com.tot.count; ISFNP&&K
esBv,b?*
/** [r3sk24
* Eri007? D
* @author 4uMMf
*/ An0N'yo"Z
public class CountBean { '\op$t/
private String countType; jN*wbqL
int countId; {J,"iJKop
/** Creates a new instance of CountData */ %cUC~, g_(
public CountBean() {} jnztCNaX
public void setCountType(String countTypes){ 4:a ~Wlp[
this.countType=countTypes; a)=|{QR>W
} (?^ F }]
public void setCountId(int countIds){ kBrA ?
this.countId=countIds; F!u)8>s+z{
} se2Y:v
public String getCountType(){ \aM-m:J
return countType; myN2G?>;
} Z8Y&#cB
public int getCountId(){ 9{j`eAUZl
return countId; 9@q!~ur
} >4kQ9lXL
} Qb>("j~Z
c_+fA
CountCache.java 3%GsTq2o
$|J+
/* XxdD)I
* CountCache.java 6Y,&