有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: jcv3ES^
Jc:*X4-'
CountBean.java jja9:$#
=)(sN"%
/* og!Uq]U/y
* CountData.java \"5%w *vl
* _D[vMr[
* Created on 2007年1月1日, 下午4:44 {BDp`uZ
* #2{ };)
* To change this template, choose Tools | Options and locate the template under ``K.4sG
* the Source Creation and Management node. Right-click the template and choose -E?h^J&U
* Open. You can then make changes to the template in the Source Editor. !~"q$T>@
*/ UvxJ _
I4gyGg$H
package com.tot.count; YjoN:z`b
Of SYOL7o
/** HmAA?J}
* 66Huqo
* @author R/A40i
*/ q?e97 a
public class CountBean { ~g~z"!K
private String countType; VctAQ|h^
int countId; DpoRR`
/** Creates a new instance of CountData */ b:WlB[5
public CountBean() {} rW&8#&
public void setCountType(String countTypes){ > & \QLo[5
this.countType=countTypes; G}AfCd4
} ^+Ec}+ Q
public void setCountId(int countIds){ LKFL2|af
this.countId=countIds; r8}GiP0|
} RWz^
MV5K
public String getCountType(){ *GTCVxu
return countType; v.c2(w/P
} }| (KI
public int getCountId(){ KPs5? X
return countId; jx+%X\zokA
} $:t;WXc.<
} r,EIOcz:
X-e)w
CountCache.java W{?7Pn?1`
|*e
>hk
/* -{-w5_B$
* CountCache.java `$fwLC3j
* <