有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: `gSJEq
UfNcI[xr
CountBean.java Njmb{L]Cps
:5-t$^R
/* ;39~G T
* CountData.java uE ^uP@d
* Swxur+hfH
* Created on 2007年1月1日, 下午4:44 9}|t`V"
* 1]wo
* To change this template, choose Tools | Options and locate the template under
(RBB0CE
* the Source Creation and Management node. Right-click the template and choose wlEmy.)H
* Open. You can then make changes to the template in the Source Editor. 2~y<l
*/ 5M?
I-m
Ge=|RAw3
package com.tot.count; L$3{L"/
sHPK8Wsg
/** Qm)c!
* ,ieew`
* @author ai]KH7
*/ cR6Rb[9 N
public class CountBean { qir8RPW
private String countType; VfT@;B6ALF
int countId; !E~czC\p6
/** Creates a new instance of CountData */ K9_@[}Ge
public CountBean() {} lhBu?q
public void setCountType(String countTypes){ 3|
F\a|N
this.countType=countTypes; u|sdQ
} R/\ qDY,@
public void setCountId(int countIds){ A kEt=vI
this.countId=countIds; ayZWt| iHA
} (r-8*)Qh8
public String getCountType(){ dk_! ~Z
return countType; wl0 i3)e:
} r<1.'F
public int getCountId(){
D}/nE>*
return countId; A(1WQUu j
} fU>4Ip1?y/
}
(2dkmn
|H'wDw8
CountCache.java H03R?S9AQ
P0l.sVqL
/* *EF`s~
* CountCache.java 4Jk[X>I~
* o<L=l Q
* Created on 2007年1月1日, 下午5:01 _}l7f
* X_ (n
* To change this template, choose Tools | Options and locate the template under b" kL)DL1L
* the Source Creation and Management node. Right-click the template and choose >/9Qgyc0
* Open. You can then make changes to the template in the Source Editor. ~mvD|$1z
*/ Q[&CtM
X8 A$&