有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: L/shF}<
LY"/ Q
CountBean.java +r '
6Rso}hF}}
/* 'del|"h!M
* CountData.java SYyH_0N
* Yq.Omr!
* Created on 2007年1月1日, 下午4:44 t+pI<c^]y
* }=++Lr4*
* To change this template, choose Tools | Options and locate the template under mu(S9
* the Source Creation and Management node. Right-click the template and choose <I}k%q'
* Open. You can then make changes to the template in the Source Editor. ^rI&BN@S
*/ aJ2-BRn
n1v%S"^
package com.tot.count; \K?3LtJ
}/6jom9U?
/**
o]
=
&
* OUD<+i,
* @author .NabK
*/ &u8BGMl2
public class CountBean { -.xs=NwB.|
private String countType; [!v:fj
int countId; |*!I(wm2i
/** Creates a new instance of CountData */ #<)u%)`
public CountBean() {} o rEo$e<
public void setCountType(String countTypes){ .n"aQ@!
this.countType=countTypes; <53~Y
} Lq yY??\@
public void setCountId(int countIds){ a7Z PV1k
this.countId=countIds; zd+8fP/UB
} h:l\kr|9
public String getCountType(){ (CEJg|,
return countType; G|.>p<q
} C8i}~x<
public int getCountId(){ ($]y*|Obn
return countId; RTSg=
} '9-8_;
} NoV2<m$
\4mw>8wA
CountCache.java ze]2-B4
B;L~hM
/* nx=Zl:Q}
* CountCache.java S.BM/M
* >lRX+?
* Created on 2007年1月1日, 下午5:01 HA>b'lqBM
* {3'z}q
* To change this template, choose Tools | Options and locate the template under *l^h;RSx
* the Source Creation and Management node. Right-click the template and choose Lylw('zZ
* Open. You can then make changes to the template in the Source Editor. Wn<