有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: C6c*y\O\7
TQb/lY9*
CountBean.java gy?uk~p
dQ;8,JzIw&
/* f5//?ek
* CountData.java z1b@JCWE
* [!U%''
* Created on 2007年1月1日, 下午4:44 9O &]!ga
* Wpf~Ji6||
* To change this template, choose Tools | Options and locate the template under 9'(^Coq
* the Source Creation and Management node. Right-click the template and choose T}J)n5U}\
* Open. You can then make changes to the template in the Source Editor. %KF I~Qk
*/ }bihlyB&Q
0(o2<d7
package com.tot.count; @=G[mc\
xVsI#`<a
/** PkFG0
* LawE3CD
* @author w
nBvJb]4l
*/ uj)vh
public class CountBean { - 5v{p
private String countType; 0B[~j7EGO
int countId; pj7al;
/** Creates a new instance of CountData */ c)Ng9p
public CountBean() {} xrXfZ>$5bM
public void setCountType(String countTypes){ x
[vbi
this.countType=countTypes; N MkOx$
} i<$?rB!i<1
public void setCountId(int countIds){ /\qzTo
this.countId=countIds; Zk~Pq%u
} VI|2vV6?
public String getCountType(){ tSni[,4Kq
return countType; +P+h$gQ
} mS}.?[d"
public int getCountId(){ 4lCbUk[l
return countId; !r6Yq,3
} 4h?@D_{k
} P_H2[d&/>D
C[{E8Tg/
CountCache.java uzb|yV'B
KXz7l\1Gb
/* mYfHBW:
* CountCache.java -1hCi!
* Bx)!I]gi_
* Created on 2007年1月1日, 下午5:01 \d.\M
* %p7onwKq0
* To change this template, choose Tools | Options and locate the template under A:4&XRYZY
* the Source Creation and Management node. Right-click the template and choose jT]R"U/Q
* Open. You can then make changes to the template in the Source Editor. b%x=7SMXO
*/ 'xG{q+jj'
7k%!D"6_R
package com.tot.count; w`<