有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: )JA9bR
<
i U"2uLgb
CountBean.java H3#rFO"C*
W6^YFN
/* o$q})!
* CountData.java Gov]^?^D-
* 7ILb&JQ!%{
* Created on 2007年1月1日, 下午4:44 [Fk|%;B/~
* 2]:Z7Ji
* To change this template, choose Tools | Options and locate the template under ~8 S2BV3@
* the Source Creation and Management node. Right-click the template and choose eXA@J[-M:
* Open. You can then make changes to the template in the Source Editor. 4ux^K:z
*/ )`5=6i
&iI5^b-P
package com.tot.count;
,hSTR)
SX1w5+p$C
/** WJU[+|J
* i+@t_pxc
* @author D;! aix3
*/ O&g$dK!Rad
public class CountBean { 6<SX%Bc~
private String countType; wN]]t~K)Q
int countId; '5etZ!:
/** Creates a new instance of CountData */ 1fMl8[!JLu
public CountBean() {} D}T+X;u)K
public void setCountType(String countTypes){ It#T\fU
this.countType=countTypes; 3]rd!Gp=*
} Mwtd<7<!A
public void setCountId(int countIds){ V:'_m'.-Y
this.countId=countIds; M$Or|HTG
} fx=HK t
public String getCountType(){ l1UN.l'p
return countType; ~O8Xj6
} ;d<RPVE:
public int getCountId(){ sjj,q?
return countId; d$5\{YLy
} jI!WE$dt
} GUcGu5tw:
Q@ghQGn#
CountCache.java -izZ D
w%?6s 3
/* ]I:h4hgw
* CountCache.java |R3A$r#-
* M
_e^KF
* Created on 2007年1月1日, 下午5:01 !n3J6%b9y/
* >A.m`w
* To change this template, choose Tools | Options and locate the template under 2)T.Ci cx
* the Source Creation and Management node. Right-click the template and choose W.m2`] &