有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Ak?9a_f
N|yA]dg[
CountBean.java a fa\6]m
=FzmifTc
/* 8xLQ"
l+"
* CountData.java *|y'%y
* ww{k_'RRJ
* Created on 2007年1月1日, 下午4:44 rN&fFI
* PA^*|^;Xh
* To change this template, choose Tools | Options and locate the template under +ywz@0nx
* the Source Creation and Management node. Right-click the template and choose jr`T6!\
* Open. You can then make changes to the template in the Source Editor. ]Ozz"4Z
*/ E{Wn&?i>A
@ym:@<D
package com.tot.count; c +]r
vFe=AY<Rt|
/** t\/H. Hb
* E<yQB39
* @author (d&" @
*/ 4BMu0["6|s
public class CountBean { f/sz/KC]~
private String countType; "o--MBq4
int countId; (f&V 7n
/** Creates a new instance of CountData */ +PYV-@q
public CountBean() {} /(~
HHN nh
public void setCountType(String countTypes){ zu}uW,XH-
this.countType=countTypes; Vx!ZF+
} I%4eX0QY=z
public void setCountId(int countIds){ dcrvEc_/
this.countId=countIds; =#2%[kG q
} lz`\Q6rZ
public String getCountType(){ &- p(3$jn7
return countType; ~~{lIO)&