有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: wqf^n-Ze
OYNPZRu
CountBean.java 0p ZX _L'
o2NU~Ub
/* w]VdIS
* CountData.java z
T#j.v
* ngQ]
* Created on 2007年1月1日, 下午4:44 n$(_(&
* O8WLulo
* To change this template, choose Tools | Options and locate the template under ADN
* the Source Creation and Management node. Right-click the template and choose G+f@m,
* Open. You can then make changes to the template in the Source Editor. VtC1TZ3-7
*/ Y,C3E>}Dq
s4Z5t$0|
package com.tot.count; -<WQ>mrB&
% wS5m#n
/** [|\BuUT'
* <Q?X'.
* @author <YBA
7i
*/ HESORa;
public class CountBean { >2?O-WXe
private String countType; 06S-3bis
int countId; `SO"F,
/** Creates a new instance of CountData */ 4F>?G{ci
public CountBean() {} <eG8xC
public void setCountType(String countTypes){ *%xmCPJ
this.countType=countTypes; X3;|h93.a
} or1D
6*'
public void setCountId(int countIds){ HX:rVHY
this.countId=countIds; }[*BC5{>
} o w<.Dh
public String getCountType(){ hM @F|t3
return countType; ,V2,FoJ 9
} r(QjVLjj`k
public int getCountId(){ !|gln)|A
return countId; 7ehs+GI
} F82_#|kpS
} C~dD'Tq]
5%n
CountCache.java
W{2(fb
i0-zGEMB.
/* -hIDL'5u-I
* CountCache.java 3<nd;@:-
* 5w+X
* Created on 2007年1月1日, 下午5:01 LE:nmo
* F7zBm53
* To change this template, choose Tools | Options and locate the template under 4^mpQ.]lO
* the Source Creation and Management node. Right-click the template and choose qm1; ^j&