有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 2:G/Oj h&]
S`pB EM
CountBean.java }~Ir&
J~|:Q.Rt`
/* c\OLf_Uf
* CountData.java Ogu";p(
* %r]V:d+
* Created on 2007年1月1日, 下午4:44 J*4T|#0
* A,4Z{f83
* To change this template, choose Tools | Options and locate the template under @:t2mz:^i
* the Source Creation and Management node. Right-click the template and choose L~E|c/
* Open. You can then make changes to the template in the Source Editor. X+QoO=02LR
*/ %+@<T<>J<k
sB wzb
package com.tot.count; /kAbGjp0
[F+*e=wjN>
/** o^W.53yX
* ,j(S'Pw
* @author T
3<2ds
*/ b<j*;n.
public class CountBean { 5M\bH'1
private String countType; v]y=+* A
int countId; y wmC>`0p
/** Creates a new instance of CountData */ [:8+ +#KD
public CountBean() {} ),XDY_9K
public void setCountType(String countTypes){ rmeGk&*R8
this.countType=countTypes; v9"03=h
} !q 9PO
public void setCountId(int countIds){ RV),E:?
this.countId=countIds; xwojjiV
} oZ>2Tt%
public String getCountType(){ Rw^X5ByJE
return countType; @3`Pq2<
} pkc*toW
public int getCountId(){ g`dAj4B
return countId; y.gjs<y
} 10CRgrZ
} H18pVh
t**MthnW
CountCache.java 5%"sv+iO
%ZX3:2
/* Ge1"+:tbJ
* CountCache.java ~cSE 9ul
* )i<Qg.@MX
* Created on 2007年1月1日, 下午5:01 >[S\NAE>
* A8
!&Y