有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: IH&|Tcf\
6NuD4Ga
CountBean.java S_4?K)n #
=^f<v_L
/* FZ<gpIv!NS
* CountData.java UiP"Ixg6
* o.g V4%
* Created on 2007年1月1日, 下午4:44 f#"J]p
* GL0L!="!
* To change this template, choose Tools | Options and locate the template under bMu+TgAT,
* the Source Creation and Management node. Right-click the template and choose S9D<8j^
* Open. You can then make changes to the template in the Source Editor. oUr66a/[U
*/ 9@:2wR |
Jk11fn;\>
package com.tot.count; kGS;sB
qu@~g cE
/** rjAn@!|:+
* T#Z^s~7&I
* @author o5O#vW2Il&
*/ c?*=|}N
public class CountBean { k[YS8g-Q
private String countType; z`}qkbvi
int countId; *3FKt&v 0
/** Creates a new instance of CountData */ 2'\H\|
public CountBean() {} dNH08q8P
public void setCountType(String countTypes){ g\:[
55;8
this.countType=countTypes; 1~`fVg
} cN6X#D
public void setCountId(int countIds){ EhvX)s
this.countId=countIds; %y[h5*y*
} DGF5CK.O
public String getCountType(){ CL;}IBd a
return countType; #&k5d:
} aEWWP]
public int getCountId(){ 1Z2HUzqh.
return countId; t+G#{n
} A#<? 4&
} V>LwqS~`
)
7@ `ut
CountCache.java .bg~>T+<
\fdv]f
/* EwT"uL*V;
* CountCache.java eA ?RK.e
* fu ,}1Mq#
* Created on 2007年1月1日, 下午5:01 qkY:3Ozw
* :#ik. D
* To change this template, choose Tools | Options and locate the template under nEy&