有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: }hn?4ny
3cJ'tRsp<
CountBean.java `Am|9LOT
t ]BG)]
/*
nS]e
* CountData.java L 0Ckw},,
* pW[TufTa
* Created on 2007年1月1日, 下午4:44 q>%B @'
* R*6TS"aL
* To change this template, choose Tools | Options and locate the template under YMo8C(
* the Source Creation and Management node. Right-click the template and choose E?]$Y[KJKs
* Open. You can then make changes to the template in the Source Editor. gYt=_+-
*/ 5B~]%_gZr
^qL<=UC.
package com.tot.count; @kSfF[4H
.nY}_&
/** Q%6zr9
* D&fOZVuqZ
* @author =bp'5h8_
*/ /%g@ ;
public class CountBean { Af\@J6viF7
private String countType; EuHQp7
int countId; );HhV,$n
/** Creates a new instance of CountData */ z^wod
public CountBean() {} p4uzw
public void setCountType(String countTypes){ n{W(8K6d@[
this.countType=countTypes; ,L%]}8EL"
} =o~mZ/ 7=M
public void setCountId(int countIds){ c6jVx_tt.
this.countId=countIds;
6(7
56
} J[}j8x?r
public String getCountType(){ /\,3AInLb
return countType; 7jw+o*;
} uBG!R#T
public int getCountId(){ ce$[H}rDB
return countId; *lDVV,T'}w
} %S%UMA.
} V1,p<>9
gR/?MJ(v
CountCache.java 2 6}3
l>|scs;TI
/* ~;b}_?%o
* CountCache.java wKJ|;o4;L
* _ow7E\70
* Created on 2007年1月1日, 下午5:01 ByE@4+9
* [$} \Gv
* To change this template, choose Tools | Options and locate the template under (e;/Smol
* the Source Creation and Management node. Right-click the template and choose _k}Qe;
* Open. You can then make changes to the template in the Source Editor. #bcZ:D@FC
*/ J<0sT=/2$
QUkP&