有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: N('S2yfDR
~(l2%(3G
CountBean.java H(DVVHx
hK9t}NE.O
/* J?qcRg`1E
* CountData.java 5@r_<J<>
* yv#c=v|
* Created on 2007年1月1日, 下午4:44 J _[e9
* R"\ub"]
* To change this template, choose Tools | Options and locate the template under C&d"#I
* the Source Creation and Management node. Right-click the template and choose B'lxlYV1
* Open. You can then make changes to the template in the Source Editor. .9[8H:Fe
*/ xTksF?u)
4E>/*F!
package com.tot.count; q!9v}R3(
v|,[5IY
/** 3 DO$^JJ.
* 1>*UbV<R;u
* @author 0[$Mo3c+'
*/ rz%[o,s
public class CountBean { 0D]Yz`n3
private String countType; !Sy'Z6%f
int countId; YCLD!S/?
/** Creates a new instance of CountData */ ~gLEh tW
public CountBean() {} w'zO(6 `
public void setCountType(String countTypes){ Fh!!T%5>C
this.countType=countTypes; 8ZDqqz^C0
} 0u&?Zy9&
public void setCountId(int countIds){ uYFcq
this.countId=countIds; T0]%(F/8
} 7&;jje[
<g
public String getCountType(){ ;]#4p8lh+
return countType; ;o)`9<es!2
} A86lyBDQ*
public int getCountId(){ z7us*8X{
return countId; nm:let7GB
} %]:vT&M
} ^?S@v1~7d
>I66R;
CountCache.java pg& ]F
]Buk9LTe
/* *l'$pJ X
* CountCache.java $M3A+6["H
* )zc8bS
* Created on 2007年1月1日, 下午5:01 GYb2m"a)
* ph&H