有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 5g2+Ar(
=I}V PxhE7
CountBean.java G.e\#_RR?
<ijmkNVS
/* :P"Gym
* CountData.java Bcon4
* L1 VTq9[3
* Created on 2007年1月1日, 下午4:44 v[3sg2.
* Y,\mrW}K
* To change this template, choose Tools | Options and locate the template under >G~;2K[
* the Source Creation and Management node. Right-click the template and choose uhLmyK
* Open. You can then make changes to the template in the Source Editor. [KJL%u|8/
*/ :+!b8[?Z
4O^1gw
package com.tot.count; )d`$2D&iY
rWqA)j*!
/** c?",kzo
* W%cPX0
* @author lM,:c.R
*/ y<(.,Nb8
public class CountBean { 9E?>B3t^
private String countType; 3R.cj
int countId; e5KF ~0`
/** Creates a new instance of CountData */ iNSJOS
public CountBean() {} gMn)<u >
public void setCountType(String countTypes){ ?0Zw ^a
this.countType=countTypes; v4aGL<SO
} a$8?0`(
public void setCountId(int countIds){ R&xd
ic!
this.countId=countIds; ) &-E@% \
} \_bX2Lg
public String getCountType(){ Yg.u8{H
return countType; Z4' v
} p\\q[6
public int getCountId(){ blv6
return countId; LJ3UB
} -wRzMT19MG
} Yl])Q|2I
cTp+M L
CountCache.java W0kq>s4
UxtZBNn8
/* 1| DI'e[X
* CountCache.java S(l^TF
* U+
=q_ <
* Created on 2007年1月1日, 下午5:01 W9~datIh>
* (eP)>G]
* To change this template, choose Tools | Options and locate the template under $h9!"f[|j
* the Source Creation and Management node. Right-click the template and choose w"|c;E1;_
* Open. You can then make changes to the template in the Source Editor. &