有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: z _\L@b
ol/@)k^s>
CountBean.java ~/-SKGzo-
.d^8?vo
/* JQ0Z%;"
* CountData.java g |?}a]G
* hLgX0QV
* Created on 2007年1月1日, 下午4:44 QK0]9
* |gP) lR
* To change this template, choose Tools | Options and locate the template under X=)L$Kd7
* the Source Creation and Management node. Right-click the template and choose ;w"h n*
* Open. You can then make changes to the template in the Source Editor. <ml?DXT
*/ JU^Y27
)^s>2 1
package com.tot.count;
lqL5V"2Y
wZ\93W-}
/** 4_j_!QH87
* 6O6B8
* @author ro<w8V9.a
*/ ^"
g?m
public class CountBean { hDW_a y4
private String countType; BV>9U5
int countId; mkyYs[
/** Creates a new instance of CountData */ _[-MyU s
public CountBean() {} h;+O96V4.
public void setCountType(String countTypes){ \M@IKE
this.countType=countTypes; rCA!b"C2
} (n?f016*%d
public void setCountId(int countIds){ ';Nc;9
this.countId=countIds; 27c0wzq
} K\xM%O?
public String getCountType(){ H.{Fw j4
return countType; iZdl0;16[
} 5!Y\STn
public int getCountId(){ ,pTZ/#vP#
return countId; &(,&mE
} 9H4"=!AAgD
} M$ieM[_T
v+Y^mV`|
CountCache.java (VN'1a (
I
F!xZ6X8
/* LsIZeL^
* CountCache.java |z_Dw$-xm
* oowofi(E
* Created on 2007年1月1日, 下午5:01 J0R{|]W8
* dS 4/spNq
* To change this template, choose Tools | Options and locate the template under +<xQF
* the Source Creation and Management node. Right-click the template and choose URm<