有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: iRsB|7v[ ,
P-4$Qksx
CountBean.java . J O3#
gdf0
/* gxVr1DIkN
* CountData.java q1:dcxR[
* 9
fB|e|
* Created on 2007年1月1日, 下午4:44 '9f0UtT|[
* >va_,Y}
* To change this template, choose Tools | Options and locate the template under =fRS UtX
* the Source Creation and Management node. Right-click the template and choose aJ(/r.1G
* Open. You can then make changes to the template in the Source Editor. 9lYfII}4(
*/ 0"OEOYs}
Qpmq@iL
package com.tot.count; ny13+Q`^
.S54:vs
/** u:p OP
* m*_X PY
* @author rk1,LsZVS
*/ #E!^oZm<Z
public class CountBean { #b[bgxm
private String countType; GO"|^W
int countId; bfz7t!A)A
/** Creates a new instance of CountData */ ,1mL=|na
public CountBean() {} -z`%x@F<&L
public void setCountType(String countTypes){ qF~9:`
this.countType=countTypes; Mn
,hmIz
} <)T| HKx
public void setCountId(int countIds){ ?3BcjD0
this.countId=countIds; o@L0ET
} n3~axRPO
public String getCountType(){ GoybkwFjZ
return countType; /lC# !$9vz
} +I3Vfv
public int getCountId(){ Q ")Xg:
return countId; r!Dk_|Cd
} Hdew5Xn(:
} -yqgs>R(d
A3/[9}(U
CountCache.java gDU!dT
*`+zf7-f
/* EX_j|/&tZ
* CountCache.java cQt&%SVT]E
* ~NK $rHwi%
* Created on 2007年1月1日, 下午5:01 ,A` |jF
* EF
:g0$
* To change this template, choose Tools | Options and locate the template under `(HD'f ud3
* the Source Creation and Management node. Right-click the template and choose 9Q,>I6`l
* Open. You can then make changes to the template in the Source Editor. }
KyoMs
*/ !rRBy3&
z9S
(<