有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: RLecKw&1{3
T%?<3/Ev!
CountBean.java n%W~+
EKq9m=Ua@o
/* VO[s:e9L
* CountData.java 3*XX@>|o
* qdNYY&6>?u
* Created on 2007年1月1日, 下午4:44 vlOMB
* (&+
~hW5d
* To change this template, choose Tools | Options and locate the template under gmy_ZVU'
* the Source Creation and Management node. Right-click the template and choose IP/
zFbc
* Open. You can then make changes to the template in the Source Editor. Rr(,i%fu
*/ ~vBmW_j
3[aCy4O
package com.tot.count; P+,\x&Vr
ep>S$a*|
/** 8H3|^J
* :Uj+iYE8Z8
* @author W UDQb5k
*/ cYmMO[4YG'
public class CountBean { l+y/ Mq^QB
private String countType; q-X)tH_+w@
int countId; |OhNQoTY
/** Creates a new instance of CountData */ Xn9TQ"[4
public CountBean() {} C] \r~f
public void setCountType(String countTypes){ h+}`mi
this.countType=countTypes; %Mz(G-I.\
} `A$yF38!
public void setCountId(int countIds){ dX,2cK[aG
this.countId=countIds; lMF j"x\
} ??ah
public String getCountType(){ d,6 Z
return countType; vw>O;u.]B
} 4Z1-RS
public int getCountId(){ j+w*Absh
return countId; D8C@x`
}
lrU}_`
} tWdj"n%
Vv0dBFe
CountCache.java _(TavL>l
=
2<
w/GX.
/* T/dchWG
* CountCache.java f[!N]*
* 2?nK71c"
* Created on 2007年1月1日, 下午5:01 U}_l]gNn
* +#A>[,U
* To change this template, choose Tools | Options and locate the template under CKmoC0.
* the Source Creation and Management node. Right-click the template and choose I[WW1P5
* Open. You can then make changes to the template in the Source Editor. p
p9Gzn C
*/ /{\tkvv-Z
`GUj.+u
package com.tot.count; uhbo/7d'7
import java.util.*; !2>gC"$nv
/** |9{l8`9}_
* W5<1@
* @author Etg'"d@[
*/ AhiZ0W"
public class CountCache { M)!8`]
public static LinkedList list=new LinkedList(); C>4y<