有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: &}_tALg
R0GD9
CountBean.java '^'PdB
?uF3Q)rCk
/* R@IwmJxX
* CountData.java Iqj?wI1)
* @k-GyV-v
* Created on 2007年1月1日, 下午4:44 ,K.Wni#m
* ,GtN6?
* To change this template, choose Tools | Options and locate the template under JUq7R%"h6
* the Source Creation and Management node. Right-click the template and choose T I yHM1+
* Open. You can then make changes to the template in the Source Editor. ndvt
$*
*/ AFsYP/g]
5E${
package com.tot.count; %^u
e
^>y|{;`
/** a,xy38T<
* aMxM3"
* @author ABq#I'H#@2
*/ Ou|kb61zg
public class CountBean { uPb. uG
private String countType; r;"Qu
int countId; Zo Ra^o
/** Creates a new instance of CountData */ hXc:y0
0
public CountBean() {} "(p&Oz
public void setCountType(String countTypes){ fz+dOIU3\L
this.countType=countTypes; )qD V3
} <II>io;
public void setCountId(int countIds){ fV!~SX6S
this.countId=countIds; ?]_A~_J!
} 4y,pzQ8a
public String getCountType(){ U@}P]'`'f
return countType; aL8Z|*
} K[q-[q#yc
public int getCountId(){ PD^Cj?wm
return countId; z
E\~Oa;
} tSTl#xy
} N1l^%Yf J
}~v0o#
I
CountCache.java %(r.`I$
h9&0"LHr
/* #0Z%4W Q
* CountCache.java }#Kl6x
* :SN/fY
* Created on 2007年1月1日, 下午5:01 &