有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: \PMKmJX0O
soVZz3F
CountBean.java Hv7D+j8M
}Keon.N?
/* >RqT7n8h
* CountData.java Jgv>$u
* fJ"~XTN}T
* Created on 2007年1月1日, 下午4:44 L+ETMk0
* gZ >orZL'
* To change this template, choose Tools | Options and locate the template under w4MMo
* the Source Creation and Management node. Right-click the template and choose & Dl'*|
* Open. You can then make changes to the template in the Source Editor. JX@6Sg<
*/ ND9>`I5
rIWN!@.J
package com.tot.count; h`;F<PFW
yJ`1},^
/** j!_^5d#d
* *(q8?x0>
* @author f!8m
*/ N9h@1'>
public class CountBean { |&RX>UW$W
private String countType; bvu<IXX=2
int countId; K8 4cE
/** Creates a new instance of CountData */ H6CGc0NS+
public CountBean() {} qH$rvD!]
public void setCountType(String countTypes){ : )"jh`
this.countType=countTypes; f`]E]5?
} mhkAI@)>
public void setCountId(int countIds){ +xdFkc
this.countId=countIds; ,,#rv-*
} `::'UfHc
public String getCountType(){ YM.IRj2/1
return countType; ,lS-;.
} y~ 4nF
public int getCountId(){ 7(USp#"
return countId; d8
Nh0!
} O+Lb***b"
} 5b4V/d*
'
. .je<
CountCache.java H{Y=&#%d
rbZ6V :
/* OO+#KyU
* CountCache.java v4a4*rBI"
* V?z{UZkR
* Created on 2007年1月1日, 下午5:01 vyOC2c8
* `1}?{ud
* To change this template, choose Tools | Options and locate the template under `iayh
* the Source Creation and Management node. Right-click the template and choose Y{|~A
* Open. You can then make changes to the template in the Source Editor. -j=&