有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: dWV.5cViP
F?Cx"JYix
CountBean.java _r+2o-ZR
$(pzh:|
/* *gMo(-tN
* CountData.java W0%cJ8~
* <PL94
* Created on 2007年1月1日, 下午4:44 Sw HrHj
* o/273I
* To change this template, choose Tools | Options and locate the template under MKIX(r(|
* the Source Creation and Management node. Right-click the template and choose \zioIfHm
* Open. You can then make changes to the template in the Source Editor. >Qg`Us#y
*/ 4'JuK{/ A7
_bB:1l?V
package com.tot.count; [5>f{L!<T<
`tKrTq>
/** 4PG]L`J{
* \fG?j@Qx
* @author Htd-E^/
*/ X5i?Bb.
public class CountBean { `l+{jrRb<
private String countType; *'D(
j#&
int countId; k2{*WF
/** Creates a new instance of CountData */ 5tUp[/]pl
public CountBean() {} ? pq#|PI)
public void setCountType(String countTypes){ ^PDz"L<*
this.countType=countTypes; \xD.rBbt
} \IB@*_G
public void setCountId(int countIds){ vAZc.=+ >
this.countId=countIds; O ;,BzA-n
} :%ms6j/B&V
public String getCountType(){ *
S4IMfp
return countType; yn=BO`sgW
} @jb
-u S
public int getCountId(){ j} ^?3<
return countId; E`68Z/%
} ,e\'Y!'
} .$nQD.X
! h7?Ap
CountCache.java :t?Z
Er(
I6
/* :l~^un|<2Y
* CountCache.java -Lh\]
* UYJMW S=
* Created on 2007年1月1日, 下午5:01 u0^Vy#@_
* )`;Q]?D
* To change this template, choose Tools | Options and locate the template under c^ $_epc*
* the Source Creation and Management node. Right-click the template and choose LLE\ ;,bv
* Open. You can then make changes to the template in the Source Editor. x'dU[f(
*/ ;!H<W[
R+vago:
package com.tot.count; '%U'%' )
import java.util.*; WE;QEA /
/** MDkcG"O
* #O3Y#2lI
* @author 9eOP:/'}w
*/ 6lW\-h`NG
public class CountCache { tf?syk+jB7
public static LinkedList list=new LinkedList(); N.r8dC
/** Creates a new instance of CountCache */ \*] l'>x1
public CountCache() {} FvX<