有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: uV~e|X
"9s
gs`> C(
CountBean.java 4#:\?HAu!
~NNv>5t5
/*
%+wF"
* CountData.java hhmGv9P
* 2-v\3voN
* Created on 2007年1月1日, 下午4:44 RH1uVdJ1
* 7Fl-(Nv`
* To change this template, choose Tools | Options and locate the template under "H1:0p
* the Source Creation and Management node. Right-click the template and choose W-D[z#)/Y
* Open. You can then make changes to the template in the Source Editor. 7lU.Nit
*/ U9#WN.noG
oT3Y!Y3=<
package com.tot.count; 2OalAY6RS
J#7y<
s
/** @!\K>G >9[
* -0 0}if7
* @author !kXeO6X@m
*/ G9RP^
public class CountBean { <zfKC
private String countType; ;fGx;D
int countId; (M`|'o!
/** Creates a new instance of CountData */ Ro r2qDF
public CountBean() {} LC-)'Z9}5
public void setCountType(String countTypes){ (vQ+e
this.countType=countTypes; <v$QM;Ff
} / L~u02?
public void setCountId(int countIds){
}B ff,q
this.countId=countIds; U8O(;+
} G$5m$\K
public String getCountType(){ ]W)
jmw'mo
return countType; \+Y!ILOI
} GDPo`#~
public int getCountId(){ HFS+QwHW
return countId; jvs[ /
} 6c<ezEJ
} Q6^x8
6fwY$K\X
CountCache.java T=\!2gt
)^
<3\e
/* ?63&g{vA
* CountCache.java \##`pa(8
* +v15[^F
* Created on 2007年1月1日, 下午5:01 i&K