有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: c9uT`h
1(i>Vt.+
CountBean.java 7ILa H|eN
cXY'>N
/* NN 6KLbC(
* CountData.java YU=ZZEVi
* yOK])&c
* Created on 2007年1月1日, 下午4:44 o w_y
* iHn!KV
* To change this template, choose Tools | Options and locate the template under Jo3(bl%u
* the Source Creation and Management node. Right-click the template and choose 8>{W:?I
* Open. You can then make changes to the template in the Source Editor. H 1D;:n
*/ 8KtgSash
n+qVT4o
package com.tot.count; ~J-|,ZMd
H~|%vjH
/** j 3MciQ`
* a9Fm Y`
* @author bfJ`}xl(8
*/ O_Rcd&<mr
public class CountBean { *sB-scD
private String countType; +%Yc4
int countId; "Wk{ 4gS7l
/** Creates a new instance of CountData */ ~'2r&?=\
public CountBean() {} 6#)Jl
public void setCountType(String countTypes){ qX+gG",8
this.countType=countTypes; R==cz^#
} =*g$#l4
public void setCountId(int countIds){ Yv>BOK
this.countId=countIds; 7p.h{F'A
} ,=Nw(GI
public String getCountType(){ VL7S7pb_
return countType; gXu^"
} lW$&fuDHF
public int getCountId(){ ^+as\
return countId; >4/L-y+
} x$n~f:1Y
} &QTeGn
V[Rrst0yo
CountCache.java rMHQzQ0%
_@!QY
/* FKox0Jmh=
* CountCache.java /> 3
* o8'Mks
* Created on 2007年1月1日, 下午5:01 'cZMRRc<
* fJWxJSdi
* To change this template, choose Tools | Options and locate the template under 2{e dW+
* the Source Creation and Management node. Right-click the template and choose 6~ 7 ;o_>
* Open. You can then make changes to the template in the Source Editor. q#99iiG1
*/ -R&E