有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: wXI6KN-
Ox9WH4E
CountBean.java DdDwMq
@c,Qj$\1
/* O(q1R#n-}+
* CountData.java i
E p{
* uvC ![j^~
* Created on 2007年1月1日, 下午4:44 9jW/"
* :'p+Ql~c
* To change this template, choose Tools | Options and locate the template under K,_d/(T4
* the Source Creation and Management node. Right-click the template and choose ;|7]%Z}%
* Open. You can then make changes to the template in the Source Editor. 3H"bivK
*/ vdA3
U?BuV
package com.tot.count; =E$Hq4I
Ot,eAiaX
/** ukNB#2"
* .rpKSf.
* @author is`O,Met
*/ :+Ti^FF`w
public class CountBean { r0jhIE#
private String countType; rUgTJx&ds
int countId; T7+_/
Qh
/** Creates a new instance of CountData */ t$+[(}@+
public CountBean() {} Z
,4G'[d
public void setCountType(String countTypes){ Q|T9tc->
this.countType=countTypes; tA;#yM;
} N;N,5rxV
public void setCountId(int countIds){ Eci,];S7
this.countId=countIds; +'aG&^k4
} (b!`klQ
public String getCountType(){ <;) qyP
return countType; Rf*cW&}%
} o}QtKf)W
public int getCountId(){ U4PnQ
K,
return countId; IbV 7}
} DVC<P}/
} 8/4i7oOC
i_<