有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: JQ@fuo %
`2`fiKm
CountBean.java SHD^}?-|
. w H*sb
/* Y#FO5O%W
* CountData.java e*C6uz9N
* Tr& }$kird
* Created on 2007年1月1日, 下午4:44 *#y;8
* \hlR]m!C
* To change this template, choose Tools | Options and locate the template under /-4$7qd
* the Source Creation and Management node. Right-click the template and choose oE?QnH3R
* Open. You can then make changes to the template in the Source Editor. 3xNMPm
*/ Q$ri=uB;+
[3N[i(Wlk
package com.tot.count; /RT%0!
B@O@1?c[
/** at6149B\)
* ]"F5;p;y
* @author /qU>5;
*/ 1zftrX~v!X
public class CountBean { ~9=aT1S|
private String countType; 5l DFp9
int countId; ]XeO0Y
/** Creates a new instance of CountData */ C5W>W4EM
public CountBean() {} S[,8TErz
public void setCountType(String countTypes){ Vw#{C>
this.countType=countTypes; Fl3#D7K
} WKmbNvN^
public void setCountId(int countIds){ K>2 #UzW
this.countId=countIds; Xf
d*D
} ,e`'4H
public String getCountType(){ -?6MU~"GK
return countType; PXzT6)
} U47}QDh
public int getCountId(){ vyI%3+N@
return countId; ,RxYd6
} 0)!Ll*L!p
} &\C [@_
93O;+Z5J
CountCache.java (*\jbK
i)ASsYG!
/* k+^'?D--'P
* CountCache.java in-C/m#
* Q;u SWt<{
* Created on 2007年1月1日, 下午5:01 U__(;
/1;
* ZJ,cQ+fn
* To change this template, choose Tools | Options and locate the template under 'b/<