有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Jj,fdP#\
^=7XA894
CountBean.java i'`[dwfS
L2\NTNY
/* K5EU?J&
* CountData.java 4$_:a?9
* p@jwHlX
* Created on 2007年1月1日, 下午4:44 "*Gp@
* J0,;F9<C#X
* To change this template, choose Tools | Options and locate the template under gMUCVKGf
* the Source Creation and Management node. Right-click the template and choose E% d3}@
* Open. You can then make changes to the template in the Source Editor. pW1(1M)[%Z
*/ *PF=dx<8
x5 ?>y{6D
package com.tot.count; POt8G
y]b&3&
/** eGj[%pk
* v 5dLjy5
* @author H?tX^HO:q
*/ $&jte_hv
public class CountBean { %#iu
private String countType; h#(J6ht
int countId; l-<EG9m@
/** Creates a new instance of CountData */ 6"<q{K
public CountBean() {} 7j8Ou3
public void setCountType(String countTypes){ -8m3L
this.countType=countTypes; @t4OpU<'*b
} C9L_`[9DO
public void setCountId(int countIds){ !i5~>p|4@
this.countId=countIds; gt)wk93d>
} $ uqB.f$
public String getCountType(){ 'o%6TWl9s
return countType; 67T=ku
} M}x]\#MMY
public int getCountId(){ @"__2\ 0
return countId; Am"e%|:
} <db>~@;X!
} `PS>"-AY2
w'7=CzfYn
CountCache.java 5Sx.'o$
l'
2C/#8F
/* tzrvIVD
* CountCache.java ki'CW4x
* !8OgaMngzF
* Created on 2007年1月1日, 下午5:01 }) Zcw1g
* zLybf:#
* To change this template, choose Tools | Options and locate the template under Zgt(zh_l
* the Source Creation and Management node. Right-click the template and choose TeNPuY~WP
* Open. You can then make changes to the template in the Source Editor. 17F<vo>l%
*/ ")@#B=8+3^
e"&QQ-q
package com.tot.count;
M<