有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: q@=3`yQ
@>Bgld&vl
CountBean.java n@te.,?A"
mMOjV_
/* DJJd_
* CountData.java MXa(Oi2Gg
* )R^&u`k
* Created on 2007年1月1日, 下午4:44 p>=i'~lQ6
* v$)ZoM6E
* To change this template, choose Tools | Options and locate the template under :B7dxE9[r
* the Source Creation and Management node. Right-click the template and choose L/c`t7
* Open. You can then make changes to the template in the Source Editor. /6{P
?)]pE
*/ aN?^vW<
?RPVd8PUhN
package com.tot.count; =1r!'<"h
+4g H=6
/**
NIh?2w"\
* IgyoBfj\d
* @author 5q,ZH6\
{
*/ s1>d)2lX
public class CountBean { M .oH,Kd6
private String countType; &WKAg:^k)
int countId; 8G )O,F7z
/** Creates a new instance of CountData */ Ud& '*,
public CountBean() {} *!r"+?0gN
public void setCountType(String countTypes){ KXf(v4
this.countType=countTypes; N8KH.P+
} SH6+'7
public void setCountId(int countIds){ 5V*R
Dh
this.countId=countIds; JUCp#[q
} &dky_H
public String getCountType(){ 6o)RsxN eu
return countType; 3lsfT-|Wt&
} )]tf|Mbu
public int getCountId(){ Qf($F,)K
return countId; gwyX%9
} @j<Q2z^
} ;DgQ8"f
=Cc]ugl7-
CountCache.java (91 YHhk{
"lRxatM
/* e'|IRhr
* CountCache.java \C<'2KZR,
* {|B
2$1':
* Created on 2007年1月1日, 下午5:01 Y[0mTL4IO
* 0[ZB ^
* To change this template, choose Tools | Options and locate the template under puAjAvIax
* the Source Creation and Management node. Right-click the template and choose Oq*;GR(Q
* Open. You can then make changes to the template in the Source Editor. Oy_%U*
*/ \7PC2IsT3
-&E