有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: JR>#PJ,N-
kcGs2Y_*&
CountBean.java 7VQ|3`!<
5i `q
/* Gw%P5 r}Y
* CountData.java >={?H?C
* f"My;K $l;
* Created on 2007年1月1日, 下午4:44 I<yd=#:n
* `p0+j
* To change this template, choose Tools | Options and locate the template under ++=t|ZS
U
* the Source Creation and Management node. Right-click the template and choose ]Y@Db5S$T
* Open. You can then make changes to the template in the Source Editor. *M6'
GT1%c
*/ EX zA(igS
GG@GjP<_
package com.tot.count; sx7;G^93
[*^`rQ
/** W?is8r:
* /o%J /|
* @author 6%?bl{pNn
*/ Z&BJ/qk
\-
public class CountBean { ]U?)_P@}
private String countType; /<ODP6Yy;
int countId; i8 t% v
/** Creates a new instance of CountData */ 2IDN?Mw
public CountBean() {} 9+><:(,
public void setCountType(String countTypes){ r:.3P
this.countType=countTypes; b'F#Y9
} D&0y0lxI@
public void setCountId(int countIds){ TrA&yXXL
this.countId=countIds; l`"i'P
} 2UqLV^ZY
public String getCountType(){ EMK>7 aks
return countType; $d\]s]}`
} ^I2+$
public int getCountId(){ mY!os91KoO
return countId; #2AKO/
} XL
SYE
} W:s`;8iM$
++{,1wY\
CountCache.java wNQhz.>y
sv}k_6XgY
/* ?VUW.-
* CountCache.java #Xdj:T<*
* MC=pN(l
* Created on 2007年1月1日, 下午5:01 Jw "fqr
* L>:YGM"sL
* To change this template, choose Tools | Options and locate the template under D3,9X#B=
* the Source Creation and Management node. Right-click the template and choose fH{ _X
* Open. You can then make changes to the template in the Source Editor.
5ZpU><