有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: G,XPT,:%
(gwj)?:
CountBean.java 9Ma0^_
rv>^TR*,!
/* oFDz;6
* CountData.java gd7^3q[$h
* tnz+bX26
* Created on 2007年1月1日, 下午4:44 Ub_4yN;
* yHeEobvb
* To change this template, choose Tools | Options and locate the template under -)jax
* the Source Creation and Management node. Right-click the template and choose c>HK9z{
* Open. You can then make changes to the template in the Source Editor. ibpzeuUl
*/ Pf<[|yu4?
oH#v6{y
package com.tot.count;
Pm+tQ
RO&H5m r%@
/** ^B/9{0n'
* 3QXjD/h
* @author N@xg:xr
*/ -.IEgggf
public class CountBean { g5Z#xszj+
private String countType; !TKkec8$
int countId; 1u|V`J)0
/** Creates a new instance of CountData */ *|% ^0#$c
public CountBean() {} B=Ym x2A9]
public void setCountType(String countTypes){ c~=B0K-
this.countType=countTypes; =JS;;PzX[
} id^sr
Mw
public void setCountId(int countIds){ (;_FIUz0
this.countId=countIds; J=W0Xi!
} VZy4_v=
public String getCountType(){ I.'b'-^
return countType; =1p8i
} Rp9fO?ZjHt
public int getCountId(){ &?,6~qm[
return countId; ?GA&f2]a
} ORN6vX(1
} +7V{ABfGl
zYY$D.
CountCache.java ziE*'p
L';MP^
/* Y&HK