有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: $20s]ywS
=~JfVozU
CountBean.java km4g}~N</
<+q$XL0
/* enumK\
* CountData.java K(3&27sGN
* P^zy; Qs7
* Created on 2007年1月1日, 下午4:44 A{(T'/~"
* On%,l
* To change this template, choose Tools | Options and locate the template under )E-E0Hl>7
* the Source Creation and Management node. Right-click the template and choose 8K^f:)Qw
* Open. You can then make changes to the template in the Source Editor. aDveU)]=1
*/ n_P(k-^U*
<T4(H[9B
package com.tot.count; a.,i.2
?0z)EPQ|
/** f[}|rf
* s OQcx\dK
* @author M=[th
*/ I.a0[E/,
public class CountBean { RJPcn)@l
private String countType; <4f,G]UH_
int countId; h.^o)T
/** Creates a new instance of CountData */ >[Rz
<yv
public CountBean() {} VDa|U9N
public void setCountType(String countTypes){ gn.Ol/6D
this.countType=countTypes; (I~\,[
} )eq}MaW+j
public void setCountId(int countIds){ H&K3"Ulw
this.countId=countIds; 85hQk+Bu4
} r<|nwFJ
public String getCountType(){ NjP ]My
return countType; \JU{xQMB
} bKUyBk,\#
public int getCountId(){ J7n5Ps\M
return countId; v.b5iv 5
} 0!_*S )
} d$[8w/5Of
BSDk9Oc
CountCache.java 1i+FL''
f3t.T=S
/* Fr;lG
* CountCache.java ugxw!cj
* Pgev) rh[
* Created on 2007年1月1日, 下午5:01 /RqhykgZ
* Snx<