有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: I`EgR?5 `
@KC;"u'C
CountBean.java 6w^Fee`>]
<4P"1#nHQ+
/* u\|Ys
* CountData.java 0"$'1g^]7
* /<oBgFMoJ
* Created on 2007年1月1日, 下午4:44 G7H'OB
&
* t~FOaSt
* To change this template, choose Tools | Options and locate the template under Hf$LWPL)lM
* the Source Creation and Management node. Right-click the template and choose KmRxbf
* Open. You can then make changes to the template in the Source Editor. JZB@K6 ~dO
*/ d!]_n|B@9
X7&
^"|:
package com.tot.count; Y/<
],1U
5*7
\Yjk?
/** qct:xviH<|
* *1
l"|=_&s
* @author %q
7gl;'
*/ n+uDg
public class CountBean { "+J[7p}`@
private String countType; w.\#!@kZ!
int countId; 4vRIJ}nQ
/** Creates a new instance of CountData */ #:3~I
public CountBean() {} Ndr4e?Xa,
public void setCountType(String countTypes){ .\+%Q)?h:
this.countType=countTypes; ;]Bkw6o
} ~b.e9FhdA
public void setCountId(int countIds){ S4BU !
this.countId=countIds; Nb@zn0A(;
} %QrpFE5V5
public String getCountType(){ >R}p*=J
return countType; E`>u*D$un~
} 5A=FEg
public int getCountId(){ _m|Tr*i8
return countId; $N)b6(}F10
} SV96eYT<
} O<?z\yBtS^
,\n%e'
CountCache.java A&6qt
\4|o5, +(@
/* VVyms7
VN
* CountCache.java ~!{y3thZ
* MUd
9R
* Created on 2007年1月1日, 下午5:01 |*WE@L5
* YX:[],FP
* To change this template, choose Tools | Options and locate the template under !o&