有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ,Si\ky7L
^g$k4
CountBean.java Aj*0nV9_
W r);A{
/* -z-58FLlO
* CountData.java Y]0oF_ :7
* \RnGKQ"4
* Created on 2007年1月1日, 下午4:44 -:Nowb
* ;l[/<J
* To change this template, choose Tools | Options and locate the template under 5-0
* the Source Creation and Management node. Right-click the template and choose A5Qzj]{ba
* Open. You can then make changes to the template in the Source Editor. uB>NwCL;
*/ Ny/bNQS
G0^WQQ4
package com.tot.count; u 3wF)B{
EtWpB g
/** fJtJ2x i
* }"06'
* @author ZsirX~W<
*/ j/5>zS
public class CountBean { ,]w-!I
private String countType; :(c2YZ
int countId; aBj~370g
/** Creates a new instance of CountData */ JR<#el
public CountBean() {} ;<1O86!
public void setCountType(String countTypes){ R|Z $aHQ
this.countType=countTypes; E<1^i;F
} !:,d^L!bh
public void setCountId(int countIds){ kZs
this.countId=countIds; ?>N82#9Q
} ?"$W=*P\o
public String getCountType(){ 4d)w2t?H%
return countType; OY*BVJ^
} YQG[8I
public int getCountId(){ Oj:O-PtN2
return countId; N'+d1
} LDN'o1$qo
}
&THM]3:
)NGBA."t
CountCache.java J6;^:()
8)&H=#E
/* IJ3[6>/M0
* CountCache.java w6y?D<
* {c<MB xk
* Created on 2007年1月1日, 下午5:01 NIrK+uC.d
* 2lDgvug
* To change this template, choose Tools | Options and locate the template under 2mP|
hp?
* the Source Creation and Management node. Right-click the template and choose /7De.O~H
* Open. You can then make changes to the template in the Source Editor. =i~/.Nu&
*/ DKqFe5rw
!ge,]@/
package com.tot.count; %@'9<