有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: k9 I%PH
37.S\gO]
CountBean.java K;H&n1
f+)L#>Gl?
/* C1n>M}b
* CountData.java 04P}-L,
* rcG"o\g@+
* Created on 2007年1月1日, 下午4:44 ,m|h<faZL
* u^I|T.w<r6
* To change this template, choose Tools | Options and locate the template under j-}O0~Jz
* the Source Creation and Management node. Right-click the template and choose <^jQo<kU
* Open. You can then make changes to the template in the Source Editor. '4Bm;&6M
*/ 0-Ku7<a
O;jrCB
package com.tot.count; (vJNHY M
/%1ON9o>
/** @:vwb\azVD
* `kXs;T6&
* @author y/7\?qfTk
*/ \?k'4rH
public class CountBean { %XQ(fj>
private String countType; -zeG1gr3
int countId; Jk
n>S#SZ
/** Creates a new instance of CountData */ G<J?"oQbRT
public CountBean() {} 16( QR-
public void setCountType(String countTypes){ AH7}/Rc
this.countType=countTypes; wc4{)qDE
} Fq<A
public void setCountId(int countIds){ V&2l5v
this.countId=countIds; 2eY_%Y0
} bwMm#f
public String getCountType(){ o|<!"AD7
return countType; 8wFJ4v3
} N5
6g+,w%)
public int getCountId(){ Z=o2H Bm7
return countId; 3;A)W18]
} SO'vpz{
} N<VJ(20y
y?? XIsF
CountCache.java Cnh \%OW
X5$ Iyis
/* xY(*.T9K
* CountCache.java 6?Ji7F
* E]-/Zbvdv
* Created on 2007年1月1日, 下午5:01 >}i E(
* &B1Wt