有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: o!:8nXw
Z%GTnG|rG
CountBean.java 5Z4-Z
>3awn*N
/* JFgoN,xn
* CountData.java Qb8KPpd
* tpy>OT$
* Created on 2007年1月1日, 下午4:44 @/r^%G
* x8;`i$
* To change this template, choose Tools | Options and locate the template under .^$YfTabq
* the Source Creation and Management node. Right-click the template and choose \A`hj~
* Open. You can then make changes to the template in the Source Editor. 4tSv{B/}
*/ Hi_G
R),zl_d_
package com.tot.count; y~IuP c
uxg9yp@|
/** Le"oAA#[
* syip; ;
* @author TO2c"7td
*/ v^ d]rSm
public class CountBean { 2MA]j T
private String countType; 9w9jpe#
int countId; )otb>w5
/** Creates a new instance of CountData */ qS&%!
public CountBean() {} r_EcMIuk
public void setCountType(String countTypes){ fw oQ'&
this.countType=countTypes; 8A{_GH{:
} vIvVq:6_3
public void setCountId(int countIds){ kY]W
Qu
this.countId=countIds; 3:%QB9qc]'
} +i\&6HGK;-
public String getCountType(){ Sx
return countType; #d{=\$=
} Kb =@ =Xta
public int getCountId(){ Z ,^9Z
return countId; 2iu_pjj
} ]nhr+;of/-
} b;|55Y
6z,&