有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: %__.-;)o
Od]wh
CountBean.java Xb*>7U/'T
lU3Xd_v
O
/* %x$mAOUv
* CountData.java 0I.!
* 'VY\ut
* Created on 2007年1月1日, 下午4:44 )4/UzR$
* ,!^w
* To change this template, choose Tools | Options and locate the template under |1 LKdP
* the Source Creation and Management node. Right-click the template and choose L\kT9wWK|
* Open. You can then make changes to the template in the Source Editor. w?p8)Q6m
*/ OoAZ t
CwfGp[|}e
package com.tot.count; SYK?5_804
(pQ$<c
/** ^m^,:]I0P
* '8Lc}-M4
* @author p WKpc
*/ *WXqN!:
public class CountBean { %u$dN9cw
private String countType; nHF
int countId; Jc9^Hyqu&
/** Creates a new instance of CountData */ $2*&\/;-E!
public CountBean() {} SB!m&;Tb
public void setCountType(String countTypes){ o&:n>:im
this.countType=countTypes; %PU{h
} qv+}|+aL:
public void setCountId(int countIds){ !yTjO
this.countId=countIds; a<V* )
} V -9z{
public String getCountType(){ qS2]|7q?Tc
return countType; xZ&S7G1