有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 1rm\ u%
<YaT r9%w
CountBean.java a{nR:zPE
` 2W^Ui,4
/* M =^d
* CountData.java a^%iAe
* pm6#azQ
* Created on 2007年1月1日, 下午4:44 p) 8S]p]
* (7Z+ De?
* To change this template, choose Tools | Options and locate the template under &<F9Z2^
* the Source Creation and Management node. Right-click the template and choose PQ&*(G
* Open. You can then make changes to the template in the Source Editor. BHY8G06
*/ |7|S>h^
=^4Z]d
package com.tot.count; hne@I1
U^dfNi@q
/** XY"b 90
* *ub2dH4/
* @author m+(Cl#+
*/ vXJPvh<
public class CountBean { E8PDIjp
private String countType; UGcmzwE
int countId; :?Ns>#6t
/** Creates a new instance of CountData */ )2[)11J9t
public CountBean() {} _(N+z.
public void setCountType(String countTypes){ igxO:]?
this.countType=countTypes; p'R<yB)V
} P 45Irir
public void setCountId(int countIds){ xp^RAVXq`
this.countId=countIds; \&Yn)|!
} 25SWIpgG
public String getCountType(){ 4aXIRu%#7
return countType; 1/}H
0\9'
} =-U0r$sK+F
public int getCountId(){ sO.MUj;
return countId; gm9*z.S\'
} 0kE[=#'.'
} F&B\ X
kXz~ez 7
CountCache.java .#( vx;
Q-<]'E#\(
/* 6
5govor
* CountCache.java %f]#P8VP
* y[_k/.1
* Created on 2007年1月1日, 下午5:01 (]]hSkE
* Sm'Tz&!
* To change this template, choose Tools | Options and locate the template under vIV|y>;g
* the Source Creation and Management node. Right-click the template and choose ,Z{\YAh1
* Open. You can then make changes to the template in the Source Editor. 8b/$Qp4d
*/ $bTtD<