有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: N} Q,
b\^ Sz{
CountBean.java )OjbmU!7
UDp"+nS
/* K8e >sU.
* CountData.java |wK)(s
* cH2
nG:H
* Created on 2007年1月1日, 下午4:44 TR
]lP<m
* YK"({Z>U
* To change this template, choose Tools | Options and locate the template under ZO0_:T#Z
* the Source Creation and Management node. Right-click the template and choose _KD(V2W
* Open. You can then make changes to the template in the Source Editor. ijoR(R^r
*/ +86\&y)
.:<c[EJ
b
package com.tot.count; dcXtT3,kpX
i37W^9 R
/** U/jJ@8
* +cjNA2@
* @author u&pLF%'EQ
*/
pRt )B`#
public class CountBean { gvwR16N
private String countType; @^;\(If2
int countId; uOougSBV,
/** Creates a new instance of CountData */ 45ct*w
public CountBean() {} 1X#`NUJ?2
public void setCountType(String countTypes){ w8@MUz}/#
this.countType=countTypes; XtQ3$0{*%
}
uiiA)j*!
public void setCountId(int countIds){ " I _T
this.countId=countIds; 1
C[#]krh
} BDB-OJ
public String getCountType(){ fnB-?8K<
return countType; Uhg[#TUK
} %e1<N8E4
public int getCountId(){ ?w<x_Lo
return countId; *NXwllrci
} m=y6E,
_
} #*Mk@XrV
EaP#~x
CountCache.java T,H]svN5p
%81tVhg
/* `_<AZ{&&
* CountCache.java qTffh{q V
* dB_\,%vAd
* Created on 2007年1月1日, 下午5:01 ]FFU,me2
* /Ee0S8!Z!1
* To change this template, choose Tools | Options and locate the template under 2<