有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Lj03Mx.2S
6,;7iA]
CountBean.java `.a~G
y
H:M;H=0
/* xu7Q^F#u
* CountData.java S?Z"){
* vS'5Lm
* Created on 2007年1月1日, 下午4:44 ,\n%e'
* A&6qt
* To change this template, choose Tools | Options and locate the template under C|Vz
`FY
* the Source Creation and Management node. Right-click the template and choose o2M4?}TpIV
* Open. You can then make changes to the template in the Source Editor. Y:}!W
*/ \@HsMV2+zN
)S6"I
package com.tot.count; 7cJh^M
w(Hio-l=
/** 42mZ.,<
* uKocEWB=/F
* @author H '(Ky
*/ Bys _8x}
public class CountBean { @fxDe[J:
private String countType;
@Iy&Qo
int countId; )~l`%+
/** Creates a new instance of CountData */ J 4OgV?
public CountBean() {} ,a/<t"
public void setCountType(String countTypes){ Cn>RUGoUsI
this.countType=countTypes; D#G(&<Q
} L cpz(W^
public void setCountId(int countIds){ Xi!`+N4
this.countId=countIds; G(1y_t
} |SF5'\d'
public String getCountType(){ ]DO"2r
return countType; 9!sR}
} Ki:.^
public int getCountId(){ ,HE +|y#
return countId; 5b^`M
} mlD 1 o
} d=_Wgz,d
9xm' 0 '
CountCache.java d2e4=/A%
Zr.6J*&