有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: TU$/3fp*
hdW",Bf'
CountBean.java }+#-\a2
qg:R+`z
/* *GbC`X)
* CountData.java # ,u7lAz
* Y"D'|i
* Created on 2007年1月1日, 下午4:44 `Q1S8i$
* ;{ XKZ}
* To change this template, choose Tools | Options and locate the template under =`xk|86f
* the Source Creation and Management node. Right-click the template and choose iN0pYqY*
* Open. You can then make changes to the template in the Source Editor. ?}m/Q"!1
*/ <?&GBCe
apa~Is1
package com.tot.count; l^:m!SA_
LVq3R 8A
/** :HYqm*v;W
* bWt>tEnf
* @author vI{JBWE,S
*/ W tnZF]1:u
public class CountBean { *;Dd:D9
private String countType; 1s-k=3)
int countId; x6* {@J&5*
/** Creates a new instance of CountData */ kCL)F\v"iT
public CountBean() {} T_\HU*\
public void setCountType(String countTypes){ N)lzX X
this.countType=countTypes; w}G2m)(
} 6%JKY+n^
public void setCountId(int countIds){ @L {x;
this.countId=countIds; M]!R}<]{
} yrnB]$hf
public String getCountType(){ {0q;:7Bt
return countType; 8;4vr@EV
} Pqo_+fL+
public int getCountId(){ Op,Ce4A
return countId; bENfEOf,
} j,80EhZ
} hc5M)0d
&}nU#)IX
CountCache.java \OHsCG27
i^G/)bq
/* J<p<