有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: \2 &)b
mj=$[y(
CountBean.java PeEf=3
:]iV*zo_
/* B;9X{"
* CountData.java s`GwRH<#
* *2N$l>ql:k
* Created on 2007年1月1日, 下午4:44 \gaGTc2&
* %>`0hk88
* To change this template, choose Tools | Options and locate the template under YQe9g>G&
* the Source Creation and Management node. Right-click the template and choose Rd|};-
* Open. You can then make changes to the template in the Source Editor. jv<BGr=4;
*/ O&!>C7
S~0 mY}
m
package com.tot.count; +Rn]6}5m\
YbB8D-
/** s<Pk[7`*
* ]n1@!qa48
* @author ^d Fdw\
*/ ag^EH"%zw
public class CountBean { gfG Mu0FjB
private String countType; )pLde_ k
int countId; ,!_$A}@0
^
/** Creates a new instance of CountData */ f?kA,!
public CountBean() {} _Z z"`
public void setCountType(String countTypes){ VeeQmR?u-
this.countType=countTypes; Tu95qL~^
}
W(a31d
public void setCountId(int countIds){ `VY -3
this.countId=countIds; \M(0@#-$C
} Eh&*"&fHR
public String getCountType(){ 0G ^73Z
return countType; z[Xs=S!]I
} E9TWLB5A)(
public int getCountId(){ 6,*hzyy}Qu
return countId; | YmQO#''
} Fl<|/DCg
} )w_0lm'v{r
If>k~aL7I
CountCache.java C-'n4AY^
;4p_lw@
/* 37Ux2t
* CountCache.java N-EVHe'}6
* ~6L\9B)
* Created on 2007年1月1日, 下午5:01 z}&w7O#
* `K37&b