有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: mmKrmM*1
+`4}bc,G
CountBean.java b{dzbmak
OVh/t#On
/* Uq+
_#{2(
* CountData.java fVN}7PH7+
* $c y:G
* Created on 2007年1月1日, 下午4:44 =4%C?(\
* yED^/=\)}
* To change this template, choose Tools | Options and locate the template under RU>vnDaC
* the Source Creation and Management node. Right-click the template and choose {oJa8~P
* Open. You can then make changes to the template in the Source Editor. 4
?c1c
*/ \S@A
/t6pa
Cg|uHI*
package com.tot.count; 88*RlxU
yR$_$N+E
/** [qI* ]
* jh?7+(Cw
* @author SmLYxH3F
*/ 6b8Klrar!
public class CountBean { pnG8c<
private String countType; -*Pt781
int countId; eS=k 48'U
/** Creates a new instance of CountData */ ]`kvq0Gyb
public CountBean() {} J-ZM1HoB
public void setCountType(String countTypes){ gdZVc9_
this.countType=countTypes; g`6wj|@ =W
} cU6#^PFu
public void setCountId(int countIds){ Rj&7|z
this.countId=countIds; Gehl/i-
} %N
public String getCountType(){ H'`(|$:|
return countType; g|HrhUT;
} 9]w0zUOL6
public int getCountId(){ ^U?(g0<"
return countId; ]VH@\
f
} WuQYEbap
} X]*/]Xx
U; xWW9
CountCache.java @iceMD.
^0
lPv!2
/* k$ M4NF~$
* CountCache.java @~XlI1g$i
* ,+BgY4OY
* Created on 2007年1月1日, 下午5:01 wEbs E<</
* eEh0T%9K
* To change this template, choose Tools | Options and locate the template under -:>#w`H
* the Source Creation and Management node. Right-click the template and choose 7EO&:b