有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: (kpn"]^'
t;P%&:"@M
CountBean.java u{0'"jVJ
hkzyI~7
/* >KjyxJ7
* CountData.java %
K$om|]p
* w7b?ve3-
* Created on 2007年1月1日, 下午4:44 \Mk;Y
* 't2dP,u<-
* To change this template, choose Tools | Options and locate the template under \3P.G S{l
* the Source Creation and Management node. Right-click the template and choose k+xj 2)d7
* Open. You can then make changes to the template in the Source Editor. O'5d6m
*/ `aY{$>$S
P;%4Imq3
package com.tot.count; 7aH E:Dnwp
d4"KM+EP?
/** 3kxI'0&T
* D]+0X8@kH7
* @author
kyQUaFG
*/ v#iKa+tx
public class CountBean { x:TBZh?@$
private String countType; 9>qc 1z
int countId; */gm! :Ym
/** Creates a new instance of CountData */ DAs&4Y`
public CountBean() {} 9Y:JA]U&8
public void setCountType(String countTypes){ GO@pwq<
this.countType=countTypes; l~.}#$P]
} 1jdv<\U
public void setCountId(int countIds){ ,E]u[7A
this.countId=countIds; 5t6!K?}
} ei 1(A
public String getCountType(){ ()=u#y
return countType; )^+v*=Dc-i
} '}a[9v76
public int getCountId(){ }s;W{Q
return countId; ny:c&XS
} Lp\89tB>
} ".&x`C
vkE[Ur>
CountCache.java qzv$E;zAl
g%z?O[CN
/* uq;,h46ki
* CountCache.java H \$04vkR
* kc&