有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: )+Y&4Qu
jJ++h1
K
CountBean.java Z$;"8XUM
F~_;o+e;X
/* &KqVN]1+^
* CountData.java ^M|K;jt>
* oJY[{-qW
* Created on 2007年1月1日, 下午4:44 6^YJ] w
* &
_K*kI:
* To change this template, choose Tools | Options and locate the template under X~RH^VYv
* the Source Creation and Management node. Right-click the template and choose z\.1>/Z=
* Open. You can then make changes to the template in the Source Editor. nyhMnp#<
*/ z $6JpG
C6@t
package com.tot.count; 'IQsve7cI
QzthTX<
/** .>]N+:O
* x /
XkD]Hq
* @author R^P_{_I*"
*/ 8$}OS-
public class CountBean { 'b[0ci:
private String countType; #*,sa
int countId; ^7u#30,}3~
/** Creates a new instance of CountData */ (5`T+pAsV
public CountBean() {} UK3a{O[5
public void setCountType(String countTypes){ `WlE|
G[
this.countType=countTypes; /f3m)pT
} Alz~-hqQ
public void setCountId(int countIds){ @ {}rG8
this.countId=countIds; q)iTn)Z!
} X?dfcS*!n
public String getCountType(){ |}S1o0v{(a
return countType; R^8B3-aA`
} ^
KH>1!
public int getCountId(){ crn k|o
return countId; CLK^ gZ
} [7\>"v6
} e4.&aIC[
}uQ${]&D
CountCache.java Do;#NLrWb
yJD>ny
/* y1,5$0@G
* CountCache.java U e*$&VlT
* r!K|E95oj9
* Created on 2007年1月1日, 下午5:01 &!1}`4$[T
* R6@uM<