有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: fQ2!sV
(YaOh^T:|
CountBean.java L3-<Kop
1v>
/* WHZe)|n
* CountData.java Q=)"om
* hWl""66+5
* Created on 2007年1月1日, 下午4:44 K7)j
* ,Zf
:R
* To change this template, choose Tools | Options and locate the template under Y*]l|)a6_]
* the Source Creation and Management node. Right-click the template and choose MoC*tImWR
* Open. You can then make changes to the template in the Source Editor. >u'/$k
*/ 9_g>BI;"8
dqIZ#;:g
package com.tot.count; S7@ZtFf
GGFar\
EzW
/** !7kAJG g
* :Vu7,o
* @author IM l9\U
*/ b(+w.R(+Ti
public class CountBean { &!H~bzg
private String countType; g~bf!
int countId; f\U? :83
/** Creates a new instance of CountData */ ^bZ<9}
public CountBean() {} k~'?"'
public void setCountType(String countTypes){ l5":[C$
this.countType=countTypes; z7NGpA(
} FZeN,
public void setCountId(int countIds){ PV5TG39qQ
this.countId=countIds; 3fbD"gL
} *K0j5dx
public String getCountType(){ *DPTkMQN
return countType; #QJ4o_
} H]T2$'U6
public int getCountId(){ w>/pQ6=OFR
return countId; Res"0Q
} t?3{s\z 8+
} muqfSF
]4LT#
CountCache.java Yc.
~qmG/z
\N'hbT=
/* R{2GQB
* CountCache.java es*_Oo1
* s>9z+;~!
* Created on 2007年1月1日, 下午5:01 %l9WZ*yZ`2
* F3H:I"4
* To change this template, choose Tools | Options and locate the template under _oMs
`"4K
* the Source Creation and Management node. Right-click the template and choose $=@9 D,R
* Open. You can then make changes to the template in the Source Editor. 7(nz<z p
*/ <