有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: {!E<hQ2<$9
U,g!KN3P
CountBean.java @ZT25CD
KnU "49
/* EmY8AN(*
* CountData.java jixU9]
* fzSZ>I0R
* Created on 2007年1月1日, 下午4:44 I ][8[UZ
* 4W^0K|fq
* To change this template, choose Tools | Options and locate the template under +IJpqFH
* the Source Creation and Management node. Right-click the template and choose /&ph-4\i
* Open. You can then make changes to the template in the Source Editor. A$|> Jt
*/ Npq=jlj
|nocz]yU$
package com.tot.count; UVU}
B?TAS
/** 6
*Q5.g
* !%5{jO1
* @author Sqfa,3?L
*/ 5t0i/&zX
public class CountBean { c*6o{x}K
private String countType;
@| 5B
int countId; ztb2Ign<
/** Creates a new instance of CountData */ =Jem.Ph
public CountBean() {} l<v/T
public void setCountType(String countTypes){ G::6?+S
this.countType=countTypes; g]jtVQH']
} .W?POJT
public void setCountId(int countIds){ nw\p3
this.countId=countIds; 8l)l9;4 6
} wX|]8f2Z
public String getCountType(){ .,EZ-&6{
return countType; TcRnjsY$
} ")Bf^DV
public int getCountId(){ '}XW
return countId; c*\^61T
} yv'mV=BMJ!
} k&^Megcb
u5idH),<
CountCache.java EiT
raWV"O
Jr1^qY`0+
/* FRfMtxvU
* CountCache.java v~@Y_`l
* ;z%& 3u/
* Created on 2007年1月1日, 下午5:01 L.|GC7$0
* D
Zh6/n#q
* To change this template, choose Tools | Options and locate the template under x<= ;=893
* the Source Creation and Management node. Right-click the template and choose w.0.||C
O
* Open. You can then make changes to the template in the Source Editor. MjG.Ili$m
*/ SSI&WZ2a
_&B