有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 7`j|tb-
Y9lbf_51
CountBean.java RXCygPT
<"j"h=tm}
/* {|t?
* CountData.java /9t*CEu\
* D*<8e?F
* Created on 2007年1月1日, 下午4:44 [qc6Q:
* z{<q0.^EFh
* To change this template, choose Tools | Options and locate the template under Lx4H/[$6D
* the Source Creation and Management node. Right-click the template and choose l,~ N~?
* Open. You can then make changes to the template in the Source Editor. # UP,;W
*/ lcuH]z
{Hrr:hC
package com.tot.count; OP\^c
O~c+$(
/** tPMgZ
* 0|f_C3
* @author 8.
~Euz
*/ btkMY<o7
public class CountBean { SO8|]Fk
private String countType; *o2_EqXL*
int countId; GtGyY0
/** Creates a new instance of CountData */ k_.j%
public CountBean() {} tL|L"t_5x
public void setCountType(String countTypes){ p]J]<QaZD
this.countType=countTypes; Cys/1DkE
} u8$~N$L
public void setCountId(int countIds){ PhI{3B/
this.countId=countIds; 123-i,epg
} PdE)m/
public String getCountType(){ /Wta$!X{-
return countType; oGU.U9~!
} C$EFh4
public int getCountId(){ QjT#GvHY
return countId; Xl
'\krz
} iI/'!85
} r.W"@vc>
Jg?pW:}R
CountCache.java x Ps&CyI
! a8h
/* Av[|.~g
* CountCache.java LOYyj?^7
* GO&R