有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 508v:?^'
yvv]iRk<
CountBean.java #A\@)wJ
{\hjKP
/* }20~5!
* CountData.java uVN2}3!)Y
* f?W_/daP
* Created on 2007年1月1日, 下午4:44 W[/Txc0$
* WUrE1%u
* To change this template, choose Tools | Options and locate the template under 0~4Ww=#
* the Source Creation and Management node. Right-click the template and choose ~bf4_5
* Open. You can then make changes to the template in the Source Editor. H%pD9'q~
*/ e>0gE`8A
DaP,3>M
package com.tot.count; AT%6K.
42M_ %l_
/** 41g
"7Mk
* F/V-@SF
* @author bI+/0Xx
*/ @CMEmgk~
public class CountBean { "zj[v1K9-A
private String countType; T[Lz4;TRk5
int countId; V_zU?}lZ^
/** Creates a new instance of CountData */ V/`vX;%
public CountBean() {} jh(T?t$&
public void setCountType(String countTypes){ (1 (~r"4I
this.countType=countTypes; 7>"dc+Fg
} qF\w#nG
public void setCountId(int countIds){ /z!Tgs4
this.countId=countIds; w p\-LO~
} Qp7h|<
public String getCountType(){ 1J([*)
return countType; {8>g?4Q#
} _iu~vU)r
public int getCountId(){ y4U|~\]
return countId; >
a;iX.K
} ncqAof(/
} oR7[[H.4
,?P< =M
CountCache.java bmu] zJ
_o[fjd
/* JkhW LQ>o
* CountCache.java LTxP@pr
* ^hXm=r4ozR
* Created on 2007年1月1日, 下午5:01 djH&)&q!
* }yVx"e)
* To change this template, choose Tools | Options and locate the template under Qk? WX
(`B
* the Source Creation and Management node. Right-click the template and choose 4C/G &w&
* Open. You can then make changes to the template in the Source Editor. da<