有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Tc2.ciU
:<%bAn
CountBean.java nHK(3Z4G
V\~.
/* 5dBftTv?
* CountData.java T U%@_vYR
* Fu7:4+
* Created on 2007年1月1日, 下午4:44 }r}*=;Ea
* ZWs
* To change this template, choose Tools | Options and locate the template under V35Vi6*p
* the Source Creation and Management node. Right-click the template and choose |dRVSVN
* Open. You can then make changes to the template in the Source Editor. 3"fDFR
*/ A_9WSXR
f~IJ4T2#N
package com.tot.count; )7q$PcY
[B0BHJ~
/** a6p0_-MF
* XTol|a=
* @author f%Q)_F[0D4
*/ +`y(S}Z
public class CountBean { +9)JtmoL
private String countType; ]5!3|UYS
int countId; OG\i?N
/** Creates a new instance of CountData */ )0{`}7X
public CountBean() {} QV4|f[Ki%
public void setCountType(String countTypes){ @SQsEq+A?\
this.countType=countTypes; z*@eQauA
} b0P3S!E
public void setCountId(int countIds){ tjdPia
this.countId=countIds; A2
l?F
} |Q?h"5i"(
public String getCountType(){ 6Z\ aJ
return countType; 'o$j~Mr
} i,Ct AbMx
public int getCountId(){ uo F.f$%"
return countId; ^$c#L1
C
} 16NHzAQ
} ?HEqv$n
\Lx=iKs<
CountCache.java rb?7i&-
fv+]iK<{
/* >7U/TVd&
* CountCache.java 1HJ:
?]
* >KKWhJ
* Created on 2007年1月1日, 下午5:01 q?,PFvs"
* 0b&