有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: i<ES/U\
b-&rMML
CountBean.java iE'_x$i
lju5+0BSb
/* 2y!n c%
* CountData.java Ij#mmj NW
* e)e(f"t6Q
* Created on 2007年1月1日, 下午4:44 qR@ESJ_
* TZgtu+&
* To change this template, choose Tools | Options and locate the template under E^-c,4'F
* the Source Creation and Management node. Right-click the template and choose |P5dv>tb
F
* Open. You can then make changes to the template in the Source Editor. Oa/^A-'Q
*/ *Dg@fxCQ
Wg}KQ6
6
package com.tot.count; 9~UR(Ts}l
hCQOwk#
/** pf8'xdExH)
* [E9iuym
* @author _`?0w#>0
*/ :qo[@ x{
public class CountBean { \n_7+[=E
private String countType; ='"Yj
int countId; L0![SE>
/** Creates a new instance of CountData */ {-5)nS^_
public CountBean() {} $1 ])>m_ct
public void setCountType(String countTypes){ ,buX|
this.countType=countTypes; IUOf/mM5
} ;u2[Ww~k
public void setCountId(int countIds){ 2O kID
WcM
this.countId=countIds; LW<LgN"L-
} V6merT79
public String getCountType(){ ci;2XLAM
return countType; gclj:7U
} |<{SSA
public int getCountId(){ 'dj3y/
k%
return countId; J`5VE$2M
} 4u5j
7`O
} ]O|>nTa
aqSOC(jU
CountCache.java oRbWqN`F.
5RLO}Vn]
/* Szzj9K
* CountCache.java [4yHXZxza
* ?w/p 9j#
* Created on 2007年1月1日, 下午5:01 ^y>V-R/N
* g=td*S
* To change this template, choose Tools | Options and locate the template under xC<