有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: *y<eK0
Z<d=v3q
CountBean.java {f4jE#a>v
X{cB%to
/* PL31(!`@d
* CountData.java h~%8p
]
* WyB^b-QmDh
* Created on 2007年1月1日, 下午4:44 ,qB@agjvo<
* Jc]k\U
* To change this template, choose Tools | Options and locate the template under Vy/G-IASb
* the Source Creation and Management node. Right-click the template and choose dqBN_P%
* Open. You can then make changes to the template in the Source Editor. (u@X5O(a
*/ Ke#Rkt
!%(kMN
package com.tot.count; t<}N>%ZO
Hv'
OO@z
/** * _usVg
* !H)!b#_
* @author +o,f:Ih
*/ ' qT\I8%
public class CountBean { 3,hu3"@k
private String countType; g^po$%I '
int countId; %ib7)8Ki0
/** Creates a new instance of CountData */ nu|,wE!i
public CountBean() {} ]TtID4qL
public void setCountType(String countTypes){ hVFZQJ?cv
this.countType=countTypes; &Wdi
5T8
} fX\y/C
public void setCountId(int countIds){ W"t^t|H'~
this.countId=countIds; ApggTzh@
} #Lk~{
public String getCountType(){ z'O+B}
return countType; ]j*uD317
} fceO|mSz_
public int getCountId(){ QaA?UzB
return countId; L0{[L
} ~GJ;;v1b2
} E*,nKJu'r
?Ycl!0m
CountCache.java H _| re
nq+6ipx
/* 1TGE>HG
* CountCache.java KP>1%ap6
* ,S`FxJcE
* Created on 2007年1月1日, 下午5:01 Fs =)*6}&
* i]@k'2N
* To change this template, choose Tools | Options and locate the template under {(tR<z)
* the Source Creation and Management node. Right-click the template and choose ]HXHz(?;F
* Open. You can then make changes to the template in the Source Editor. N
K@6U_/W
*/ c&