有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ^i3~i?\,P
j, SOL9yg
CountBean.java n@pm5f
`v*UY
/* y`"b%P)+T
* CountData.java m'Jk!eo
* +xqPyR
* Created on 2007年1月1日, 下午4:44 hFORs.L&G
* OiB*,TWV
* To change this template, choose Tools | Options and locate the template under %9z N U
* the Source Creation and Management node. Right-click the template and choose |meo
* Open. You can then make changes to the template in the Source Editor. &3x
\wH/_
*/ E?c)WA2iH
wGd4:W
package com.tot.count; (*63G4Nz\
W~15[r0
/** ld~8g,
* 19)fN-0Z
* @author q6Q;9 ,
*/ DlB"o.
public class CountBean { hZ0p /Bdv
private String countType; 0qXkWGB
int countId; G~Xh4*#J
/** Creates a new instance of CountData */ L8<Yk`jx
public CountBean() {} 3y!yz3E
public void setCountType(String countTypes){ ;Qpp[V`
this.countType=countTypes; AXBv']Y
} P0m;AqS#R
public void setCountId(int countIds){ 3nfw:.
this.countId=countIds; 5 pNbO[
} } D5*
public String getCountType(){ qaBjV6loy
return countType; Wsb=SM7;
} 5oz[Njq4
public int getCountId(){ ()=u#y
return countId; 0sjw`<ic
} zV)Ob0M7U
} }s;W{Q
># FO0R
CountCache.java 8l|v#^v
&]VCZQL
/* fMjn8.
* CountCache.java 3z Jbb3e
* ZN)a}\]
* Created on 2007年1月1日, 下午5:01 r>+Hwj0>
* O=os ,'"
* To change this template, choose Tools | Options and locate the template under kc&