有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: w9Nk8OsL
Ga`
8oY+~
CountBean.java pV1;gqXNS
0*j\i@
/* 3f:]*U+O
* CountData.java '1d0
*5+6k
* Hi U/fi`
* Created on 2007年1月1日, 下午4:44 #v4^,$k>
* T0 cm+|S
* To change this template, choose Tools | Options and locate the template under ~/Y8wxg
* the Source Creation and Management node. Right-click the template and choose QaXdO=3
* Open. You can then make changes to the template in the Source Editor. [=:4^S|M
*/ VeH%E.:
.5tXwxad"
package com.tot.count; W k "_lJ
|aj]]l[@S
/** H~:g=Zw
* V'9OGn2v
* @author slLTZ]
*/ xscR Bx
public class CountBean { I]~s{I(EK
private String countType; ncpA\E;ff^
int countId; T,B%iZ gCh
/** Creates a new instance of CountData */ QRF:6bAxsL
public CountBean() {} %v^qQWy=*
public void setCountType(String countTypes){ k"cKxzB
this.countType=countTypes; G$~hAZ
} Y"dTm;&
public void setCountId(int countIds){ k1LbWR1%wB
this.countId=countIds; hJX;/~L
} % QaWg2Y=
public String getCountType(){ R^.c
return countType; /q!_f!<q4x
} EPM(hxCIQ
public int getCountId(){ S-brV\v7
return countId; buHUBn[3)
} !H @nAz
} UaHN*@
fUJe{C<H
CountCache.java 5!6}g<z&L
f%REN3=5K
/* GB}X
* CountCache.java ke'OT>8
* }-vP~I
* Created on 2007年1月1日, 下午5:01 ^SS9BQ*m
* ^(:n a6C
* To change this template, choose Tools | Options and locate the template under L)Da1<O
* the Source Creation and Management node. Right-click the template and choose sZokiFJ
* Open. You can then make changes to the template in the Source Editor. [U7r>&