有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ^_\m@
wT- -i@@
CountBean.java 0_ST2I"Ln
\.i ejB
/* p<'pqf
* CountData.java k"gm;,`
* ~ L%,9
* Created on 2007年1月1日, 下午4:44 "#gKI/[qxq
* klAlS%
* To change this template, choose Tools | Options and locate the template under +U
J~/XV
* the Source Creation and Management node. Right-click the template and choose ;%
KS?;%[
* Open. You can then make changes to the template in the Source Editor. B.od{@I(Xp
*/ FIfLDT+ Wh
~E8/m_> rU
package com.tot.count; 3]9wfT%d
,7s+-sRG
/** ZG1TRF "
* ^pu8\K;~
* @author w<THPFFF"
*/ Wd!Z`,R
public class CountBean { $PRd'YdL/
private String countType; Zy9IRZe4U
int countId; =s*c(>
/** Creates a new instance of CountData */ )K]p^lO
public CountBean() {} wAW{{ p
public void setCountType(String countTypes){ 6p&2A
this.countType=countTypes; ( z)#}TC
} V*O[8s%5v
public void setCountId(int countIds){ H1q,w|O9j
this.countId=countIds; p|nPu*R-\
} "{E%Y*
public String getCountType(){ ~"\v(\P e
return countType; Ws0)B8y,|
} ,.2qh|Ol
public int getCountId(){ DeW{#c6
return countId; DVwB}W~
} g.!k>_g`
} XSN=0N!GB
P8h|2,c%
CountCache.java JBHPI@Qt%
@>$qb|j
/* H)Me!^@[D
* CountCache.java 'j{o!T0
* )i.pE]!+
* Created on 2007年1月1日, 下午5:01 w{ _g"X
* qTbc?S46pt
* To change this template, choose Tools | Options and locate the template under A:y^9+Da
* the Source Creation and Management node. Right-click the template and choose j~.tyxOq#
* Open. You can then make changes to the template in the Source Editor. 0S>L0qp
*/ |BhL.
/CyFe<