有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: qhEv6Yxfw6
>Icr4?zq
CountBean.java fSkDD>&
>?, Zn
/* ;]u9o}[
2
* CountData.java VPe0\?!d
* FEaT}/h;
* Created on 2007年1月1日, 下午4:44 =l/6-j^
* #z|Q $
* To change this template, choose Tools | Options and locate the template under s/E|Z1pg3
* the Source Creation and Management node. Right-click the template and choose Xw-[Sf]p
* Open. You can then make changes to the template in the Source Editor. Y{p$%
*/ g8W,Xq+
DxJ;C09xNa
package com.tot.count; XBQt:7[<
nlwqS Xw
/** =dmr,WE
* ;mkkaW,D*
* @author x HRSzYn$
*/ bGPE0}b
public class CountBean { l/&.H F
private String countType; LQ jbEYp
int countId; e$# *t
/** Creates a new instance of CountData */ |A8@r&
public CountBean() {} 2cR[~\_9.
public void setCountType(String countTypes){ zLpCKndj
this.countType=countTypes; K~N$s"Qx
} &mwd0%4
public void setCountId(int countIds){ E/P~HE{
this.countId=countIds; O>~,RI!
} <+`%=r)4
public String getCountType(){ .%zcm
return countType; CU'JvVe3
} tt"<1
z@
public int getCountId(){ 'nmA!s
return countId; k }=<51c
} ?=VvFfv%
} RkF#NCnL;
p3I"LY
CountCache.java kT%wt1T4
(}: s[cs
/* I;(3)^QH#
* CountCache.java BVQy@:K/
* $><