有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ^~$\ g]
tdep|sD
CountBean.java ?]#OM_,8
qP3q
/* [dB$U}SEj
* CountData.java *6Q|}b[qcD
* +r]zs^'
* Created on 2007年1月1日, 下午4:44 {tw+#}T a
* \'Ssn(s
* To change this template, choose Tools | Options and locate the template under wN97_Y=`n
* the Source Creation and Management node. Right-click the template and choose ^C/
* Open. You can then make changes to the template in the Source Editor. }4&/VvN
*/ mM_
k^4:
qnChM;)
package com.tot.count; `zA#z />
VT\"q1)p
/** X|}2_B
* j.m(ltGh
* @author #Ex p51
*/ ;),"M{"v
public class CountBean { Es!Q8.
private String countType; B(_WZa!
int countId; k()$:-V
/** Creates a new instance of CountData */ 0|c}p([~
public CountBean() {} f>2MI4nMG
public void setCountType(String countTypes){ wM~H(=s`D
this.countType=countTypes; wi_'iv
} SmhGZ
public void setCountId(int countIds){ ]y#3@
this.countId=countIds; _,haD)1g~
} }!p`1]gem
public String getCountType(){ NI aFI(
return countType; ;=4Xz\2
} *bd[S0l
public int getCountId(){ 3B0PGvCI1
return countId; cA)[XpQ:+W
} oDn|2Sdqd
} TP%+.#Fu
.fAv*pUzU
CountCache.java M}O}:1Par
t)f-mQz)
/* k&