有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: k&iScMgCTH
Ss! 3{VW
CountBean.java dN/ "1%9)
W)msaq,
/* $"{3yLg
* CountData.java ^H6d;n
* uPC qO+f
* Created on 2007年1月1日, 下午4:44 bNpIC/#0K
* }>X\"
* To change this template, choose Tools | Options and locate the template under rspoSPnY1
* the Source Creation and Management node. Right-click the template and choose p6y0W`U
* Open. You can then make changes to the template in the Source Editor. 'BdmFKy1
*/ u$=ogp=0
~73i^3yf
package com.tot.count; VIYksv
iVi3 :7*
/** ENx@Ex
* LLn{2,jfQ
* @author #+Yp^6zg
*/ @f5@0A\0
public class CountBean { ^A"lkV7
private String countType; feI[M;7u
int countId; 'W?v.W &
/** Creates a new instance of CountData */ 1'v !9
public CountBean() {} k4F"UG-`
public void setCountType(String countTypes){ &e]]F#
this.countType=countTypes; XL7;^AE^Wl
} AXh3LA
public void setCountId(int countIds){ V)1:LLRW
this.countId=countIds; !`
M;#
} lO2T/1iMTW
public String getCountType(){ TcKvSdr'
return countType; l'7Mw%6{
} 1ntkM?
public int getCountId(){ Vy%
:\p+
return countId; aq0iNbv@
} i2FD1*=/?
} WE.$a t{*h
5Q$r@&qp
CountCache.java x>^3]m
b$goF
}b'g
/* [<Os~bfOv
* CountCache.java %0NkIQ`C
* {7=WU4$
* Created on 2007年1月1日, 下午5:01 '6o`^u>
* xI@$aTGq
* To change this template, choose Tools | Options and locate the template under YA"Ti9-EV
* the Source Creation and Management node. Right-click the template and choose *,W!FxJ
* Open. You can then make changes to the template in the Source Editor. B?;' lDz*
*/ 2&