有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: f4uK_{
]F-{)j
CountBean.java 7:;P>sF@
Pg5 1}{
/* m%m8002
* CountData.java H]YPMG<
* ]{dg"J
* Created on 2007年1月1日, 下午4:44 "Sl";.
* 3 bGpK9M~
* To change this template, choose Tools | Options and locate the template under 2c}>}A 4
* the Source Creation and Management node. Right-click the template and choose MA"DP7e?v
* Open. You can then make changes to the template in the Source Editor. M7En%sBp
*/ 7Sr7a{
pnDD9u-4;
package com.tot.count; 7ej"q
"M2HiV
/** AOeptv^k3}
* 9QZ;F4 r
* @author Xa+ u>1"2"
*/ Ao 1*a%-.
public class CountBean { h@l5MH=|%
private String countType; ]Y:|%rvVH
int countId; /)6<`S(
/** Creates a new instance of CountData */ 3%'$AM}+s
public CountBean() {} )j!22tlL
public void setCountType(String countTypes){ NfKi,^O
this.countType=countTypes; r\a9<nZ{
} wn5CaP(]8
public void setCountId(int countIds){ ->:G+<
this.countId=countIds; 2{g~6U.
} Hb IRE
public String getCountType(){ K6_{AuL}4
return countType; )9J&M