有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: :A
%^^F%
%J:SO_6
CountBean.java gWABY%!}
v~3B:k:?l
/* 3f" %G\
* CountData.java vK7\JZ>
* UJfT!= =U
* Created on 2007年1月1日, 下午4:44 >d"3<S ;b
* (&|_quP7O
* To change this template, choose Tools | Options and locate the template under @E( 7V(m/
* the Source Creation and Management node. Right-click the template and choose HoV^Y6
* Open. You can then make changes to the template in the Source Editor. Oa;X+
*/ EN{]Qb06A
!Cgx.
package com.tot.count; " 96yp4v@
%*aJLn+]_R
/** Jd\apBIf
* 9)xUA;Qw?z
* @author )VL96 did
*/ !Fo*e
public class CountBean { M.-"U+#aD
private String countType; <IW#ME
int countId; D jk C
/** Creates a new instance of CountData */ Uz cx6sw
public CountBean() {} 2%*MW"Q
public void setCountType(String countTypes){ c4&' D;=
this.countType=countTypes; Sxdsv9w
} o1&:ry
public void setCountId(int countIds){ du$|lxC
this.countId=countIds; Mb3}7 @/[
} Om{l>24i.\
public String getCountType(){ k#[F`
return countType; (b?{xf'G
} +3s%E{
public int getCountId(){ M(#m0xB
return countId; u2oKH{/z
} |KB0P@=a
} :m86
hBE.
D=:04V}2+
CountCache.java !D!~^\
hA\K</h.
/* [."[pY
* CountCache.java
!fBF|*/
* t8^m`W
* Created on 2007年1月1日, 下午5:01 Y(cN}44
* +&zYZA