有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: H][TH2H1
(v?@evQ
CountBean.java xL_QTj
%TN$
/* ,YM=?No
* CountData.java rR@]`@9
* l=XZBe*[g'
* Created on 2007年1月1日, 下午4:44 ?@@$)2_*u
* }Y!V3s1bm
* To change this template, choose Tools | Options and locate the template under iSf%N>y'K
* the Source Creation and Management node. Right-click the template and choose \m)s"Sh.
* Open. You can then make changes to the template in the Source Editor. %52e^,//
*/ XuJyso9kA
X~VI} dJ
package com.tot.count; =:g\I6'a
=t_+ajY%
/** `m(ZX\W]
* A 94:(z;{
* @author h*;c"/7
*/ Y S7lB
public class CountBean { c$[2tZ
private String countType;
5:gpynE|
int countId; 2&S^\kf
/** Creates a new instance of CountData */ ~`e!$=
public CountBean() {} ' u<I S/w
public void setCountType(String countTypes){ }Jh.+k|_
this.countType=countTypes; a K6dy\
} a7_Q8iMe
public void setCountId(int countIds){ r>8`gAhx
this.countId=countIds; .a2R2~35
} .&b^6$dC
public String getCountType(){ Hz,Gn9:p
return countType; GtmoFSZ
} Y{j~;G@Wl
public int getCountId(){ `/m]K~~
return countId; hb8oq3*x
} /[Fk>Vhp
} ^3sv2wh^|8
M)K!!Jqh
CountCache.java D#'CRJh;7
$9\8?gS
/* HHw&BN