有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 8i^
./P
9y[U\[H
CountBean.java H{*rV>%
|J@
&lBlq
/* P\@kqf~pC
* CountData.java uNEl]Q]<e]
* IPTFx
)]G
* Created on 2007年1月1日, 下午4:44 `#ff`j|a
* B3yTN6-
* To change this template, choose Tools | Options and locate the template under GsO(\hR6^
* the Source Creation and Management node. Right-click the template and choose Z6b]EcP)#
* Open. You can then make changes to the template in the Source Editor. CY=lN5!J
*/ I\Y N!
N*[b26
package com.tot.count; N=U`BhL_
pq_U?_5Z'r
/** <^$ppwk$
* ES^JRX
* @author u[SqZftmO
*/ e)s
l
public class CountBean { cD9U^SOS
private String countType; Ne;0fkO
int countId; 8_wh9
/** Creates a new instance of CountData */ 1\{FK Ot
public CountBean() {} AcJrJS)~
public void setCountType(String countTypes){ HS*Y%*
this.countType=countTypes; .(8V
} u)zv`m
public void setCountId(int countIds){ 7m%12=Im5
this.countId=countIds; VL5VYv=:
} k&L/JzzI
public String getCountType(){ fVZ92Xw
B
return countType; +tt!xfy
} : &nF>
public int getCountId(){ '5Kj"aD%
return countId; +2tFX
} # bjK]+
} l['p^-I
M*cF'go
CountCache.java FbMtor
y5KeUMcu
/* LRaO}-<b
* CountCache.java {2Ew^Li
* :
Wtpg
* Created on 2007年1月1日, 下午5:01 MGK?FJn_?
* 7}MnvWP
* To change this template, choose Tools | Options and locate the template under ;xUo(^t7>
* the Source Creation and Management node. Right-click the template and choose `<P:ly.
* Open. You can then make changes to the template in the Source Editor. FjizPg/|!
*/ >S0kiGDV{
/oJ &