有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: QR!8 n
KrQ8//Ih
CountBean.java u vo2W!
u S$:J:Drx
/* N'L3Oa\%
* CountData.java K-$gTV
* x(e=@/qp
* Created on 2007年1月1日, 下午4:44 D`;Q?fC
* $<)k-Cf
* To change this template, choose Tools | Options and locate the template under f
IUz%YFn
* the Source Creation and Management node. Right-click the template and choose d7xd"
* Open. You can then make changes to the template in the Source Editor. 1D
/{Y
*/ +U(m b
O
-a`A.
package com.tot.count; Kt,ENbF
e]\{ Ia
/** aqTMOWyeu
* EUvxil
* @author } k[gR I]
*/ qDqgU
public class CountBean { `>@n6>f
private String countType; Pv.z~~lY
int countId; $u"t/_%
/** Creates a new instance of CountData */ =sG9]a<I
public CountBean() {} )v!>U<eprD
public void setCountType(String countTypes){ D`=hP(y^
this.countType=countTypes; QI@!QU$K&
} `P&L. m]|
public void setCountId(int countIds){ W/PZD (
this.countId=countIds; sR`WV6!9
} Qh )QdW4
public String getCountType(){ .bh>_ W_h
return countType; :tu_@3bg-
} DkP%1Crdr
public int getCountId(){ tlU&p'
return countId; :@6,|2be=
} h"S+8Y:1{k
} `[JX}<~i
Re <G#*^
CountCache.java M[ea!an
*$nz<?
/* 4_3
DQx9s
* CountCache.java y0Pr[XZ
* i%7b)t[y
* Created on 2007年1月1日, 下午5:01 gt5
* b??k|q
* To change this template, choose Tools | Options and locate the template under ;C8'7
* the Source Creation and Management node. Right-click the template and choose *)c,~R^
* Open. You can then make changes to the template in the Source Editor. g->cgExj
*/ P=K+!3ZXo
A*ImruV
package com.tot.count; .!kqIx*3
import java.util.*; |okS7.|IX
/** ,c:Fa)-
* 0zg\thL
* @author 2nOoG/6
E
*/ 3IqYp K(s
public class CountCache { YShtoaCx>
public static LinkedList list=new LinkedList(); ~%9ofXy
/** Creates a new instance of CountCache */ pPcn
F`A
public CountCache() {}
<!h&h