有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: \Wn0,%x2
FQgc\-8tm
CountBean.java 4#fgUlV
}vXf}2C
/* R #\o*Ta
* CountData.java k^:+Pp
* &~
.n}h&
* Created on 2007年1月1日, 下午4:44 &$x1^
* !D!1%@
e
* To change this template, choose Tools | Options and locate the template under ,WKWin
* the Source Creation and Management node. Right-click the template and choose 9EU0R
H
* Open. You can then make changes to the template in the Source Editor. s6YnNJ,SK
*/ {Rv0@)P$
:W6R]y
package com.tot.count; KB\A<(o,
,QZNH?Cp/
/** 5/f"dX
* gNj~o^6|@
* @author <`P7^
'z!
*/ 1oSU>I_i
public class CountBean { VS\+"TPuH
private String countType; l.Yq4qW
int countId; C"[d bh!
/** Creates a new instance of CountData */ ]T<\d-!CZN
public CountBean() {} t91z<Y|
public void setCountType(String countTypes){ 5_yu4{@;y
this.countType=countTypes; Z<4Du
} +W}dO#
public void setCountId(int countIds){ dSkx*#FEE
this.countId=countIds; 9N*!C{VW
} X[;-SXq
public String getCountType(){ d+iV19 #i
return countType; +)06*"I
} ./r#\X)dc
public int getCountId(){ 8IQqDEY^
return countId; -NL=^O$G
} y/\0qQ/
} ^dP]3D1
@
4^uwZ:
CountCache.java )"sJaHx<
G>?'b
/* 6jpfo'uB$
* CountCache.java +j!$88%Z{
* BHrNDpv
* Created on 2007年1月1日, 下午5:01 &