有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Fw? ;Y%
|Z'NMJU
CountBean.java HTiqErD2_
|!:ImX@
/* tn!z^W
* CountData.java n:d]Z2b
* ZLw7-H6Fh
* Created on 2007年1月1日, 下午4:44 f(~xdR))eh
* u&Ts'j
* To change this template, choose Tools | Options and locate the template under |:Gz9u +
* the Source Creation and Management node. Right-click the template and choose .|`JS?L[
* Open. You can then make changes to the template in the Source Editor. d1VNTB
*/ CnyCEIO-
{E`[`Kf
package com.tot.count; m?bd6'&FR
:#W40rUb
/** xp-.,^q\w
* p.^glz >B
* @author 3`[f<XaL
*/ mpfc2>6Il.
public class CountBean { '7AlE!7%
private String countType; KLD)h,]
int countId; spter35b[
/** Creates a new instance of CountData */ Q SPneYD
public CountBean() {} A.tONPi
public void setCountType(String countTypes){ j]th6
this.countType=countTypes; |6/k2d{,(
} A8 V7\
public void setCountId(int countIds){ _V\rs{
5
this.countId=countIds; #T:#!MKa
} Y^DS~CrM
public String getCountType(){ d#E]>:w9
return countType; o}H7;v8H
} )jkX&7x
public int getCountId(){ ?,~B@Kx
return countId; #G2~#\
} (#x<qi,T
} .w=( G
;v%Fw!b032
CountCache.java HnU; N S3J
(3 xCW
/* *ub]M3O
* CountCache.java /W&R