有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 'c[4-m3bg
?,e7v.b
CountBean.java vwQY_J8
|0YDCMq(
/* g/ONr,l`-
* CountData.java @$'k1f(u>
* NN1d?cOn
* Created on 2007年1月1日, 下午4:44 td-2[Sy
* (UWP=L1
* To change this template, choose Tools | Options and locate the template under zOA{S~>
* the Source Creation and Management node. Right-click the template and choose TS+itU62
* Open. You can then make changes to the template in the Source Editor. Z4NNrA#
*/ n%PHHu
qPsf`nI7
package com.tot.count; Arh0m. w
nxH=Ut7{
/** HJ[@;F|aU
* u 0KVp6`
* @author (Qmpz
*/ d
dB}mk6
public class CountBean { "O1\]"j
private String countType; X3zkUMk
int countId; &~oBJar
/** Creates a new instance of CountData */ @,0W(
public CountBean() {} :'RmT3
public void setCountType(String countTypes){ ]5W|^%
this.countType=countTypes; Gs]m; "o|
} \zioIfHm
public void setCountId(int countIds){ 0Q>f,}W%>
this.countId=countIds; -Z)j"J
} vd`;(4i#X
public String getCountType(){ kBZnR$Cl
return countType; guJS;VC6U
} ?,8|K B
public int getCountId(){ !K:
return countId; \FOoIY!.x
} apsR26\^
} j} ^?3<
( <~
CountCache.java ,z A9*
:u$nH9kwv
/* ph*9,\c8
* CountCache.java ia#Z$I6
* .}'49=c
* Created on 2007年1月1日, 下午5:01 c^ $_epc*
* j>f
* To change this template, choose Tools | Options and locate the template under 8 w-2Q
* the Source Creation and Management node. Right-click the template and choose z7B>7}i-
* Open. You can then make changes to the template in the Source Editor. -1'O
*/ yV`H_iC
fyYHwG
package com.tot.count; tf?syk+jB7
import java.util.*; @Z9X^Y+u^h
/** FvX<