有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ^pA|ubZ
Z|+SC \Y
CountBean.java -ZqN~5>j)
*fVs|
/* ~yz7/?A)TS
* CountData.java -#T?C]}
* I;kKY
* Created on 2007年1月1日, 下午4:44 is_`UDaB
* f.rc~UI?
* To change this template, choose Tools | Options and locate the template under O.4ty)*
* the Source Creation and Management node. Right-click the template and choose (m|w&oA/
* Open. You can then make changes to the template in the Source Editor. SAswP
*/ xh
Sp<|X_
vG9A'R'P
package com.tot.count; ,W"Q)cL
aV`4M VWOz
/** \v.16o bH
* o<2H~2/
* @author b6BeOR*ps
*/ RMU]GCa
public class CountBean { j2NnDz'
private String countType; n)$T
zND
int countId; ) 9h5a+Z
/** Creates a new instance of CountData */ J8w#J
public CountBean() {} KZ^W@*`D
public void setCountType(String countTypes){ Qe<DX"
this.countType=countTypes; V4p4m@z^u
} hKP!;R
public void setCountId(int countIds){ {X$8yy2zC5
this.countId=countIds; 16=tHo8|
} .z7%74p
public String getCountType(){ j<w";I&Diz
return countType; Xi3:Ok6FZ
} A\J|eSG'$
public int getCountId(){ !DFT}eu
return countId; KsI[
} ((L=1]w
} KMZ:$H
gE8p**LT+
CountCache.java bQc-ryC+.
yZFm<_9>
/* Nq
%@(K
* CountCache.java dX|(n.}
* XUeBK/aQ{
* Created on 2007年1月1日, 下午5:01 g}nlb.b]{m
* iDej{95
* To change this template, choose Tools | Options and locate the template under xKIzEN
&
* the Source Creation and Management node. Right-click the template and choose b#cXn4<