有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ~&?57Sw*m
=r4sF!g
CountBean.java zo1T`"Y
#{*5rKiL
/* 15@2h
* CountData.java eC"k-a8j+
* egK~w8`W%
* Created on 2007年1月1日, 下午4:44 r?itd)WC<X
* mv>0j<C91
* To change this template, choose Tools | Options and locate the template under 4> uN H5
* the Source Creation and Management node. Right-click the template and choose b@c(Nv
* Open. You can then make changes to the template in the Source Editor. Nw9@E R
*/ v%$l(
:zX^H9'E<(
package com.tot.count; |sI@m@
eL>wKu:r
/** {yv_Ni*6!
* ,4S[<(T"
* @author
)ut$644R
*/ 4#{f8
public class CountBean { [[HCP8Wk
private String countType; Zb=;\l*&
int countId; X!:J1'FE
/** Creates a new instance of CountData */ O1UArD
public CountBean() {} ber&!9
public void setCountType(String countTypes){ )w~1VcnJEp
this.countType=countTypes; Mq#m;v$E
} dG7d}0Ou'
public void setCountId(int countIds){ O&MH5^I
this.countId=countIds; 'z^'+}iyv
} je@&|9h
public String getCountType(){ v-N4&9)%9
return countType; :2H]DDg(
} P4HoKoj2`
public int getCountId(){ e/cHH34
return countId; 'Kk/
J+6U
} `v@Z|rv,
} 3$xpZm60
8!0fT}
CountCache.java qH0JZdk
Oe
x
/* etT9}RbQ
* CountCache.java cpl Ny?UIC
* pj<aMh
* Created on 2007年1月1日, 下午5:01 6/#+#T
* c0Bqm
* To change this template, choose Tools | Options and locate the template under |||m5(`S
* the Source Creation and Management node. Right-click the template and choose L*dGo,oN
* Open. You can then make changes to the template in the Source Editor. xe^M2$clb\
*/
T*mR9 8i
pdm(7^
package com.tot.count; epKr6
xq
import java.util.*; jI'?7@32`
/** !?_CIt$p
* K\KQ(N8F
* @author Vpp$yM&?
*/ * #E_KW1RV
public class CountCache { C+P.7]?&