有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 6,ZfC<)
h6*&1r
CountBean.java 2(-J9y|
?P+n0S!
/* z/JoUje
* CountData.java KuU]enC3
* %:v59:i}
* Created on 2007年1月1日, 下午4:44 @R5jUPUVV
* kWF/SsE
* To change this template, choose Tools | Options and locate the template under *^BW[C/CTR
* the Source Creation and Management node. Right-click the template and choose 6m.ChlO/
* Open. You can then make changes to the template in the Source Editor. "[PxLq5
*/ Zu4|1W
L|y4u;-Q
package com.tot.count; F{:ZHCm
0XrB+nt
/** b7
pD#v
* X5@SLkJ-`
* @author ^w0V{qF{
*/ 61Z#;2]
public class CountBean { -_m>C2$6x
private String countType; w/8`]q
int countId; CDDx %#eG>
/** Creates a new instance of CountData */ 7x/S4Gs'4
public CountBean() {} E<[_L!2
public void setCountType(String countTypes){ -BY'E$]4
this.countType=countTypes; bYuQ"K
A$
} 7eQE[C
public void setCountId(int countIds){ j\^0BTZ
this.countId=countIds;
T 4}SF
} xW$F-n
public String getCountType(){ t/;@~jfr@
return countType; \m.ap+dFa
} j@kL`Q\&I
public int getCountId(){ /`M>3q[
return countId; hEO#uAR^Z
} 4H7
3a5f
} 9;Z2.P"w
63s<U/N
CountCache.java +N161vo7
?[$=5?
/* BrW1:2w
>\
* CountCache.java ;2o+|U@
* @/S6P-4
* Created on 2007年1月1日, 下午5:01 IrAc&Eh