有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: pGEYke NU
I`Goc!5t
CountBean.java pUtd_8
*PQu9>1w
/* v,z s
dr"d
* CountData.java %Ci`OhT
* Z^? 1MJ:`
* Created on 2007年1月1日, 下午4:44 U(#)[S,
* eHr|U$Rpo
* To change this template, choose Tools | Options and locate the template under oL?(;
`"&
* the Source Creation and Management node. Right-click the template and choose ?
tre)
* Open. You can then make changes to the template in the Source Editor. +%vBDcf
*/ +c&n7
i
oCoFj
package com.tot.count; Fr{u=0 X
n^<3E; a
/** ]C.x8(2!f
* :EOx>Pf_9)
* @author
$50rj
*/ O 1TJJ8
public class CountBean { f+>l-6M+p
private String countType; sjh>i>t
int countId; c 32IO&W4
/** Creates a new instance of CountData */ .Cv0Ze
public CountBean() {} S;a'@5
public void setCountType(String countTypes){ K"~Tk`[0Q
this.countType=countTypes; h%'4V<V
} ShXk\"
public void setCountId(int countIds){ yh9fHN)F
this.countId=countIds; {ctEjgiE
} /7W N,a
public String getCountType(){ cBICG",TA
return countType; H:9Z.|{Gv
} 566vjE
public int getCountId(){ m\a_0!K
return countId; R?aE:\A
} 6u-@_/O5R3
} / S
rGb7p`J
CountCache.java ~Ab nksR
biwV7<
/* ~F5JN^5Y
* CountCache.java [NQ\(VQ1c
* 5f+ziiZ
* Created on 2007年1月1日, 下午5:01 GA&mM