有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: YzEOfHL,
VOg'_#I
CountBean.java -?IF'5z
``{GU}n
/* N6A|
* CountData.java xnw' &E
* (VHPcoL
* Created on 2007年1月1日, 下午4:44 :ee vc7
* muFWFq&yP
* To change this template, choose Tools | Options and locate the template under >Af0S;S
* the Source Creation and Management node. Right-click the template and choose sP=^5K`g
* Open. You can then make changes to the template in the Source Editor. aJ1{9 5ea
*/ 4gmlK,a
g2u\gR5
package com.tot.count; i;IhsKO0R
Nm%#rZrN~Q
/** Uw3wR!:
* |X6R2I
* @author Rz*GRe
*/ <KoOJMx(
public class CountBean { [W3sveqj&
private String countType; e$rPXRf
int countId; {QOy'
8/
/** Creates a new instance of CountData */ A#i[Us|
public CountBean() {} #2Iw%H 2q&
public void setCountType(String countTypes){ hC]:+.Q+
this.countType=countTypes; RfCu5Kn
} =xSf-\F
public void setCountId(int countIds){ G}}Lp~
this.countId=countIds; sEL0h4
} |fgh
ryI,
public String getCountType(){ #hXvGon$?
return countType; +u&3pK>f
} t/3qD7L
public int getCountId(){ 0&tr3!h\
return countId; yDRi
} ^B7Ls{
} =OTu8_ d0t
MvaX>n!o
CountCache.java >m%7dU
\uJ+~db=
/* Fp]ErDan
* CountCache.java cXYE!(
* 6C
?,V3Z
* Created on 2007年1月1日, 下午5:01 <