有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: RWTv,pLK
7-e)V{A`w
CountBean.java KU33P>a"[k
.:RoD?px
/* [Z
Ea3/
* CountData.java Bb:jy!jq_
* *N'B(j/
* Created on 2007年1月1日, 下午4:44 ?\\
]u
* h"%6tpV-
* To change this template, choose Tools | Options and locate the template under tGmyTBgx
* the Source Creation and Management node. Right-click the template and choose N.eSf
* Open. You can then make changes to the template in the Source Editor. 7SAu">lIl
*/ oL}FD !}
z=)5M*h
package com.tot.count; "P<~bw5
8Qu].nKe
/** [zf9UUc~
* T_AZCl4d
* @author FIU(2
*/ ci3{k"
public class CountBean { 9M01}
private String countType; 9zO;sg;3
int countId; kV6>O C&^
/** Creates a new instance of CountData */ {AIZ,
public CountBean() {} Bfw>2
public void setCountType(String countTypes){ P!bm$h*3?
this.countType=countTypes; }aX).u
} yJb;V#
public void setCountId(int countIds){ j?z(fs-
this.countId=countIds; Y,E:?
} AS;{O>}54
public String getCountType(){ k )){1O
return countType; B u4N~0
} *QLl
jGe
public int getCountId(){ 4\sS
return countId; d G:=tf&1R
} I[t)V*L9
} Vi#(x9.
~q|^z[7
CountCache.java v/yk T9@;
/.WD'*H
/* gn(n</\/O
* CountCache.java 3v0)oK
* Nt/*VYUn
* Created on 2007年1月1日, 下午5:01 HM[BFF[;/
* kFk+TXLDIt
* To change this template, choose Tools | Options and locate the template under O~aS&g/sf
* the Source Creation and Management node. Right-click the template and choose &