有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: xOKLc!J
YI877T9>
CountBean.java <l#|I'hP
Lo<-;;vQ
/* vZ&{
* CountData.java ZmXO3,sf)
* jyLE
* Created on 2007年1月1日, 下午4:44 l0
Eh?
* ZqONK^
* To change this template, choose Tools | Options and locate the template under \sSt _|+
* the Source Creation and Management node. Right-click the template and choose -@I+IKz
* Open. You can then make changes to the template in the Source Editor. 2aDjt{7P
*/ @k|V4
%z9lCTmy
package com.tot.count; 5{PT
y Tb OBl
/** tz6N,4J?
* cs-wqxTX[$
* @author nq/SGo[c
*/ SV?^i `
public class CountBean { qk+RZ>T<o
private String countType; 6_&uYA<8pE
int countId; E"/r*C+T
/** Creates a new instance of CountData */ GR%h3HO2&
public CountBean() {} N I*x):bx
public void setCountType(String countTypes){ QEC4!$L^
this.countType=countTypes; 1ZrJ7a7=
} ZUA%ZkX=F
public void setCountId(int countIds){ [& d"Z2gK
this.countId=countIds; {:%A
} ,f[`C-\Q%
public String getCountType(){ 3*v&6/K
return countType; C"gH>G
} gP13n!7
public int getCountId(){ 3g{T+c*
return countId; aioN)V
}
BH<jnQ
} ozCH1V{p
rGqT[~{t
CountCache.java ]di^H>,xU
~d9@m#_T#~
/* j,Vir"-)
* CountCache.java Fr|Ts>Kx
* #
o;\5MOE%
* Created on 2007年1月1日, 下午5:01 (fTi1
I!
* p]]*H2UD
* To change this template, choose Tools | Options and locate the template under A8zh27[w%
* the Source Creation and Management node. Right-click the template and choose N E/ _
* Open. You can then make changes to the template in the Source Editor. ,zP.ch0K
*/ |eu:qn8
*a[iq`499
package com.tot.count; J Yesk
import java.util.*; `pJWZ:3
/** ( +x!wX( x
* -Uo"!o>x|
* @author
%&81xAt
*/ |PaVb4j
public class CountCache { &UextG