有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: [="moh2*f
sO~N2
CountBean.java 1W"9u
JU1U=Lu."
/* _Oh;._PS
* CountData.java WIQt5=-
* 69`9!heu
* Created on 2007年1月1日, 下午4:44 l)Q,*i
* bv)E>%Yy
* To change this template, choose Tools | Options and locate the template under p}}}~ lC/
* the Source Creation and Management node. Right-click the template and choose b^;19]/RW
* Open. You can then make changes to the template in the Source Editor. t9zPJQlT}
*/ \# lh b
axxdW)+K
package com.tot.count; @$F(({?
Fx/9T2%=
/** GmcxN<
* LGgEq-
* @author J<H$B +;qR
*/ m Wsegq4
public class CountBean { 9 %,_G.
private String countType; `Z{;
c
int countId; I`5F&8J{
/** Creates a new instance of CountData */ L` V6\Ix(I
public CountBean() {} L>).o%(R
public void setCountType(String countTypes){ i/,G=yA
this.countType=countTypes; VX[{X8PkS
} EJNj.c-#
public void setCountId(int countIds){ n,9 *!1y
this.countId=countIds; Z>7Oez>
} OV;Ho
public String getCountType(){ GLv}|>W
return countType; tV[?WA[xt
} [f:>tRdH
public int getCountId(){ qF%wl
return countId; }V ;PaX
} +`yDW N?7
} +)qPUKb?
[t: =%&B
CountCache.java oB&s