有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: tN=B9bm3j
/L8Q[`;.
CountBean.java _>8ZL)NQQ
W4Ey]y"
/* wtCz%!OYB
* CountData.java P"LbWZ6Nj
* 6;g"`l51
* Created on 2007年1月1日, 下午4:44 )V<ML7_?
* |<l
sv
* To change this template, choose Tools | Options and locate the template under A&OU;j]
* the Source Creation and Management node. Right-click the template and choose fWKI~/eUY|
* Open. You can then make changes to the template in the Source Editor. ;x*_h
*/ ~5[#c27E9
9H9 P'lx9
package com.tot.count; LwV4p6A
tO$/|B74Bz
/** h|tdK;)
* )
N*,cTE
* @author 0L_JP9e
*/ O9#8%p%
)
public class CountBean { _s/5oRHA
private String countType; v&p|9C@
int countId; HrH-e=j
/** Creates a new instance of CountData */ 5J^S-K^r
public CountBean() {} 82.::J'e
public void setCountType(String countTypes){ Wp"+\{@)
this.countType=countTypes; Z6eM~$Y
} N,9W18
@
public void setCountId(int countIds){ "NY[&S
this.countId=countIds; EIqe|a+
} ]Z?y\L*M-
public String getCountType(){ X!,2/WT
return countType; roDE?7x1
} 0drt,k
public int getCountId(){ AM4lAq_
return countId; 18ApHp
} 8LI,'XZ
} 1PD{m{
WdEVT,jjh
CountCache.java 038|>l-9[
:C*7DS
/* 50#iC@1
* CountCache.java uHj"nd13
* OT[&a6