有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: }"?nU4q;S
)w2K&Zr0
CountBean.java <2O7R}j7v
KBw9(
/* r<X 4ER
* CountData.java -9>LvLU
* dG-or
* Created on 2007年1月1日, 下午4:44 XQ3*
* 4Kn9*V
* To change this template, choose Tools | Options and locate the template under ur<eew@8@i
* the Source Creation and Management node. Right-click the template and choose P B(
* Open. You can then make changes to the template in the Source Editor. mPfUJ#rS
*/ ]TBtLU3
o9Txo
(tYU
package com.tot.count; qwF*(pTHq
S2&9#6
/** %8bzs?QI
* +an^e'
* @author ^{*f3m/
*/ {[,Wn:
public class CountBean { zn
V1kqGU
private String countType; )nNCB=YF!
int countId; 'ZC}9=_g
/** Creates a new instance of CountData */ B3dA%\'
public CountBean() {} [.j]V-61
public void setCountType(String countTypes){ #PslrA.
E
this.countType=countTypes; ]A]Ft!`6z
} n^AP"1l8?0
public void setCountId(int countIds){ Xqg.kX
this.countId=countIds; 4W!\4Va
} BjyXQ9D
public String getCountType(){ -jxWlO
return countType; *
{gxI<
} dY/u<4
public int getCountId(){ +[whh
return countId; 4e+BqCriC*
} *5y
W
} n{64g+
V~T`&
CountCache.java '<%Nw-
"*w)puD
/* j,=*WG
* CountCache.java ?""\
* F_nZvv[H?
* Created on 2007年1月1日, 下午5:01 t=Z&