有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: VNwOD-b/]
e_}tK1XY
CountBean.java ?Kg_bvoR
d^8n
/* NInZ~4:
* CountData.java :xk+`` T
* r-No\u_
* Created on 2007年1月1日, 下午4:44 piFZu/~Gq\
* 8WpZ"
* To change this template, choose Tools | Options and locate the template under @w(X}q1
* the Source Creation and Management node. Right-click the template and choose =7F?'&LC
* Open. You can then make changes to the template in the Source Editor. C(vQR~_
*/ pGr4b:N
,I
H~
package com.tot.count; vCUbbQz
7n*"9Ai(
/** G4ycP8
* nF]zd%h
* @author a,h]DkD
*/ +zK?1llt
public class CountBean { EY0,Q {
private String countType; 84coi
int countId; e?pQuF~
/** Creates a new instance of CountData */ T1%}H3
public CountBean() {} xT-`dS0u
public void setCountType(String countTypes){ OHt^e7\
this.countType=countTypes; 'n}]
} zm3$)*p1
public void setCountId(int countIds){ [x'D+!
this.countId=countIds; _k#GjAPM
} GK[Hs1/
public String getCountType(){ bX
6uGu
7
return countType; a%/D~5Z
} M\RHFTB<C
public int getCountId(){ hFnUw26P
return countId; )Myx(w"S
} yd[4l%G(zS
} |uI~}pSG
@}pcj2K#
CountCache.java iU~xb?,,
hV&