有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 56JxHQu
v`r![QpYf
CountBean.java 'nIKkQ" N
]A&pXAM
/* \X2r?
* CountData.java x$hT+z6DUC
* S:lie*Aux*
* Created on 2007年1月1日, 下午4:44 N
T>[
2<
* Nn#;Kjul.
* To change this template, choose Tools | Options and locate the template under b^:frjaE3
* the Source Creation and Management node. Right-click the template and choose N&yr?b'!-*
* Open. You can then make changes to the template in the Source Editor. &K*Kr=9N
*/ 1K#%mV_
g@zhhBtQ
package com.tot.count; SPT?Tt
w2H^q3*
/** 'pnOHT
* 4iDqd
* @author eC3 ~| G_O
*/ j=dGNi)R
public class CountBean { QXu[<V
private String countType; 2#(dfEAy
int countId; }U'VVPh_
/** Creates a new instance of CountData */ mY[*(a
public CountBean() {} ;e{e
?,[
public void setCountType(String countTypes){
7NvnCs
this.countType=countTypes; 0`/CoP<U
} TKp2C5bX
public void setCountId(int countIds){ <v6W
l\
this.countId=countIds; EQtY b"_
} :b0|v`FU
public String getCountType(){ %Yt;)q3U
return countType; *C);IdhK%y
} e I9#JM|2
public int getCountId(){ Hqtv`3g
return countId; -^Qm_lN
} 8<x&
Xd
} 7|xu)zYB
O"X:3srJ`
CountCache.java ?AO22N|j
uPy5<