有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: [Y6ZcO/-i
x|3G}[=
CountBean.java ,*;g+[Bhpl
~&+8m=
/* 4TaHS!9
* CountData.java szy2"~hm
* Kp/l2?J"
* Created on 2007年1月1日, 下午4:44 {JW_ZJx
* 9NqZ&S
* To change this template, choose Tools | Options and locate the template under 4aG}ex-s|
* the Source Creation and Management node. Right-click the template and choose w-``kID
* Open. You can then make changes to the template in the Source Editor. Oi~.z@@
*/ !Ee&e~"
D*)"?LG
package com.tot.count; (}CA?/
"D
ivsq^
/** 05;J7T<
* QH6_nZY
* @author ,uS}wJAX
*/ 5K$d4KT
public class CountBean { *BQy$dfE
private String countType; kJ B u7
int countId; _;G|3>5u
/** Creates a new instance of CountData */ IHe?/oUL"b
public CountBean() {} *GM.2``e
public void setCountType(String countTypes){ SCXtBZ`.G
this.countType=countTypes; Q% J!
} <GoZ>
public void setCountId(int countIds){ tnw6[U!rh=
this.countId=countIds; CSMx]jbb
} [3(lk_t
public String getCountType(){ f`p"uLNo<
return countType; HO39>:c
} $eh>.c'&]
public int getCountId(){ @Y+9")?
return countId; *g 2N&U
} '_o(I
} <#7j~ <
Br"K{g?
CountCache.java 0u ,nSvch
hu-6V="^9
/* h)
W|~y@
* CountCache.java lf2(h4[1R
* @86I|cY
* Created on 2007年1月1日, 下午5:01 H`8}w{ft&
* rh6m
* To change this template, choose Tools | Options and locate the template under [u/W h+
* the Source Creation and Management node. Right-click the template and choose fMRMQR=6B
* Open. You can then make changes to the template in the Source Editor. UjS,<>fm
*/ /@K1"/fqH
o,=dm@j
package com.tot.count; I>spJ5ls
import java.util.*; )dI `yf
/** e}W|wJ):j@
* MrpT5|t
* @author 76EMS?e
*/ >3y:cPTM5
public class CountCache { GP=&S|hi
public static LinkedList list=new LinkedList(); "A&