有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: o< b
fCa
lR7!
CountBean.java wOUCe#P|r
'!X`X=
/* :TrP3wV_
* CountData.java '\H
& EJ'
* >a@1y8B
* Created on 2007年1月1日, 下午4:44 S%p,.0_
* ^p4`o>
* To change this template, choose Tools | Options and locate the template under \R&ZWJKh
* the Source Creation and Management node. Right-click the template and choose >CCy2W^W
* Open. You can then make changes to the template in the Source Editor. s,J\nbj0h
*/ f[zKA{R
,9|7{j|u
package com.tot.count; v'L"sgW6I
d;%~\+)x4
/** (|W6p%(
* GLY,<O>D5
* @author Gyu =}
*/ L_Z`UhD3{
public class CountBean { -{3^~vW|<
private String countType; $LR~c)}1I
int countId; #\~m}O,
/** Creates a new instance of CountData */ {w>ofyqfp&
public CountBean() {} CNiJuj`
public void setCountType(String countTypes){
fNr*\=$
this.countType=countTypes; e,vgD kI;
} uF,%N
public void setCountId(int countIds){ _uh@fRyh
this.countId=countIds; @zR_[s
} w#(E+s~}
public String getCountType(){ 9MRe?
return countType; oz'jt} ?
}
$v{sb,
public int getCountId(){ wj$3L3
return countId; g[2[
zIB=
} w2"]%WS %
} 7<Ut/1$MI
i/N6 8
CountCache.java H_JT"~_2
+],2smd@N
/* ~}YgZ/U7T
* CountCache.java bB.nevb9p
* =Oh/4TbW[
* Created on 2007年1月1日, 下午5:01 o,1Fzdh6(
* uN9.U _
* To change this template, choose Tools | Options and locate the template under arPqVMVr
* the Source Creation and Management node. Right-click the template and choose IOUzj{G#
* Open. You can then make changes to the template in the Source Editor. K!jau|FS
*/ 1eqFMf
'\7&I