有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Z`BK/:vo3H
0C*7K?/
CountBean.java `V3Fx{
hiw|2Y&`
/* [66!bM&
* CountData.java O,A{3DAe0
* y#$CMf
-q^
* Created on 2007年1月1日, 下午4:44 n\.V qe
* PJ'E/C)i
* To change this template, choose Tools | Options and locate the template under ,i@:5X/t
* the Source Creation and Management node. Right-click the template and choose F.v{-8GV
* Open. You can then make changes to the template in the Source Editor. [ps*uva
*/
6B
?twh)
-FlzEZ
package com.tot.count; o\)F}j&b#=
@{pLk4E
/** ]}(H0?OQR
* qWKAM@
* @author g
SAt@2*U2
*/ q8Z<{#oXu
public class CountBean { ~**.|%Kc
private String countType; k,F6Tx
int countId; Gm.]sE?.
/** Creates a new instance of CountData */ f.`*Qg L
public CountBean() {} x7x\Y(@
public void setCountType(String countTypes){ }<y7bqA
this.countType=countTypes; r_;Nt
} _Z,\Vw:\F
public void setCountId(int countIds){ y%bF&
this.countId=countIds; [bNx^VP*
} VD]zz
^
public String getCountType(){ k/gZ,
return countType; L4|`;WP
} c#tjp(-
public int getCountId(){ Y0K[Sm>
return countId; wtV#l4
}
)sp4Ie
} ([LSsZ]sj
bl(RyAgA
CountCache.java JNUt$h
{9aE5kR
/* do+.aOC
* CountCache.java 6,9>g0y'NG
* :s6o"VkW
* Created on 2007年1月1日, 下午5:01 gH7|=W
* LRG6:&
* To change this template, choose Tools | Options and locate the template under Gvqxi|
* the Source Creation and Management node. Right-click the template and choose YgV817OV
* Open. You can then make changes to the template in the Source Editor. 6}Y#= }
*/ 6s/&