有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: /*8Ms`
MHVHEwr.{
CountBean.java `d[ja,
J3B]JttU
/* oAgO3x
* CountData.java 7 Ed6o
* ,TAzJ
* Created on 2007年1月1日, 下午4:44 Tv{X$`%
* $|yO
mh
* To change this template, choose Tools | Options and locate the template under ~ST7@-D0
* the Source Creation and Management node. Right-click the template and choose V:w=h>z8
* Open. You can then make changes to the template in the Source Editor. [j:]YR
*/ .w `1;o
P|OjtI
package com.tot.count; nUL8*#p-
'y?(s+
/** StP7t
* _lE0_X|d
* @author `E),G;I
*/ MWS=$N)v*
public class CountBean { P'4jz&4
private String countType; 3d2|vQx,K
int countId; 8W|qm;J98
/** Creates a new instance of CountData */ OBY
public CountBean() {} D:gskK+o6M
public void setCountType(String countTypes){ }!-K )j .
this.countType=countTypes; ?{"_9g9
} XD8MF)$9
public void setCountId(int countIds){ >~kSe=Hsb4
this.countId=countIds; |X6]#&g7
} :-=,([TJ
public String getCountType(){ s4RqMO5eI
return countType; 72gQ<Si
} {/x["2a1
public int getCountId(){ J0e~s
return countId; 75t\= 6#
} =?}
t7}#
} sz' IGy%
|d* K'+
CountCache.java IQFt4{aK3
4wZ{Z
2w
/* ptS1d$
* CountCache.java )|88wa(M
* d85\GEF9i
* Created on 2007年1月1日, 下午5:01 9}{i8
<