有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: YN4P
>d
R`=IYnoOA
CountBean.java #|*;~:fz
}8WpX2U
/* #r 1
$=GY
* CountData.java aq3evm
* :6LOb f\01
* Created on 2007年1月1日, 下午4:44 cqeId&Cg
* uE:#m.Q
* To change this template, choose Tools | Options and locate the template under R= HN>(U
* the Source Creation and Management node. Right-click the template and choose {y0*cC
* Open. You can then make changes to the template in the Source Editor. :K{`0U&l5
*/ %o<&O(Y
#FF5xe
package com.tot.count; 9Vk61x6
q|2{W.P5qi
/** ;}IF'ANA
* ~Av]LW
* @author Y>!9P\Xe
*/ #m
3WZ3t$
public class CountBean { `9Ngax=_
private String countType; mm%w0dOb"
int countId; G1B~?i2$ ?
/** Creates a new instance of CountData */ 9BLz
public CountBean() {} tjk Y[
public void setCountType(String countTypes){ XboOvdt^|
this.countType=countTypes; `< y[V
} o)n8,k&nm
public void setCountId(int countIds){ Zx25H"5j
this.countId=countIds; Faa:h#
} Q"8)'dL'
public String getCountType(){ uR)itmc?
return countType; &nn!{S^
} G/(oQA
public int getCountId(){ fT._Os?i
return countId; mquna"}N
} !_<. 6ja
} `{I,!to
5WP[-J)
CountCache.java DLyHC=%{+h
@&+h3dV.V
/* ?t)y/@eG
* CountCache.java 7|zt'.56[
* P;KbS~ SlC
* Created on 2007年1月1日, 下午5:01 [OG-ZcNu?
* O|,+@qtH
* To change this template, choose Tools | Options and locate the template under Pb} &c
* the Source Creation and Management node. Right-click the template and choose `(;d+fof
* Open. You can then make changes to the template in the Source Editor. .5L/<
*/ i#lvt#2J0
m'k`p5[=h
package com.tot.count; &g,K5at
import java.util.*; c%pW'UE&
/** CCq<y
* !=&]#-;b
* @author <)Kjf/x
*/ T'XAcH
public class CountCache { (#c5Q&