有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: f~u]fpkz
j(!M
CountBean.java #5kQn>R
|2\6X's
/* [ds:LQq)/
* CountData.java a[:0<Ek
* n^|n6(EZ
* Created on 2007年1月1日, 下午4:44 =Uta5$\a)
* LqTyE
* To change this template, choose Tools | Options and locate the template under s% "MaDz
* the Source Creation and Management node. Right-click the template and choose /a%5!)NE%
* Open. You can then make changes to the template in the Source Editor. K+D`U6&
*/ yVm~5Y&Z
5tg
package com.tot.count; 1O1/P,u+
?k~(E`ZE3
/** "z\T$/
* }+0{opY4R
* @author ;CD.8f]N
*/ cs7TAX
public class CountBean { "_JGe#=
private String countType; aE6I|6W?
int countId; =yiRB?
/** Creates a new instance of CountData */ Z&%#,0>]
public CountBean() {} w4 <FC$
public void setCountType(String countTypes){ oBr/CW
this.countType=countTypes; vBUx)l
} RF
4u\ \
public void setCountId(int countIds){
(bi}?V*
this.countId=countIds; @^:R1c![s
} uh3%}2'P
public String getCountType(){ G}CzeLw
return countType; Cs7YD~,
} w:
~66 TCI
public int getCountId(){ q_5k2'4K
return countId; 716JnG>
} IMjnj|Fj
} !Ac <A.
U(DK~#}
CountCache.java gk\IivPb
3hr&