有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: TJp(
= %\;7
CountBean.java ePa1 @dI
7?qRY9Qu
/*
$F`jM/B6
* CountData.java &M*&oi (
* yfnqu4Cn
* Created on 2007年1月1日, 下午4:44 T`Sp!
* |k{?\ (h;
* To change this template, choose Tools | Options and locate the template under "+[:\
* the Source Creation and Management node. Right-click the template and choose _hMMm6a|
* Open. You can then make changes to the template in the Source Editor. @]Aul9.h
*/ *Ny^XQ_ X
T""X~+{Z@
package com.tot.count; N9r02c
kb Fr
/** ]tanvJG}'
* h$_Wh(
* @author #^"\WG7{
*/ dMp7 ,{FhF
public class CountBean { 68kxw1xY
private String countType; Ge8&_7
int countId; =4/LixsV|
/** Creates a new instance of CountData */ Ny/bNQS
public CountBean() {} &%ej=O
public void setCountType(String countTypes){ /x"gpKwsB
this.countType=countTypes; xO`w|k
} `Yn^ -W
public void setCountId(int countIds){ no?TEXp*
this.countId=countIds; !Ui3}
} x#|=.T
public String getCountType(){ 2[}^ zTtA
return countType; R0(Nw7!d/[
} {:$0j|zL1
public int getCountId(){ ?C(Z\"IX
return countId; 3Wrl_V
} 9t(B{S
} C0[Rf.*
!u.{<51b
CountCache.java jJg9M'@2!
URck#5
/* [R)?93
* CountCache.java c@1C|
* J*F-tRuEw
* Created on 2007年1月1日, 下午5:01 5YUn{qtD
* [CGvM{
* To change this template, choose Tools | Options and locate the template under 6|r`
k75.
* the Source Creation and Management node. Right-click the template and choose ?d-(M' v.
* Open. You can then make changes to the template in the Source Editor. j
wlmWO6
*/ %@'9<