有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: RTJ\|#w
9S y |:J0
CountBean.java (sfy14>\
vpoYb
/* WcG}9)9
* CountData.java }C<<l5/ z
* !I8m(axW
* Created on 2007年1月1日, 下午4:44 v"LH^!/
* SFiK_;
* To change this template, choose Tools | Options and locate the template under 8(b
C.
* the Source Creation and Management node. Right-click the template and choose KH~o0 W
* Open. You can then make changes to the template in the Source Editor. 'Y%@fZf x
*/ 4dgo*9
aYBc)LCd
package com.tot.count; T|L_+(M{
9r efv
/** k\NwH?ppu
* k-zkb2
* @author q9^6A90
*/ C;EC4n+s
public class CountBean { $ncJc
private String countType; ptlcG9d-
int countId; s[}4Q|s%
/** Creates a new instance of CountData */ .EXe3!J)!
public CountBean() {} K!\$M BI
public void setCountType(String countTypes){ V?0Yzg$sy
this.countType=countTypes; }=fVO<Rv
} Wt ,t5
public void setCountId(int countIds){ #AN]mH
this.countId=countIds; jk\04k
} NO%x
2dx0
public String getCountType(){ ?}tWI7KI
return countType; L6ifT`;T
} a*g7uaoP
public int getCountId(){ 'Wv`^{y <^
return countId; gl$ Ks+od
} W~QH"Sq
} FB\lUO)U\c
us0{y7(p
CountCache.java 6zf3A:]&{
l5*sCp*Z
/* 6HK
dBW$/
* CountCache.java Uh tk`2O
* Jj:Bi&C
* Created on 2007年1月1日, 下午5:01 JR_s-&