有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 4UL"f<7 T
y1Br4K5C
CountBean.java kazgI>"Q8
}nM+"(}
/* ,|+{C~Ojx
* CountData.java t:.X=/02
* siuDg,uqK5
* Created on 2007年1月1日, 下午4:44 U>b.MIBX
* SPTx-b[
* To change this template, choose Tools | Options and locate the template under \SmYxdU'>
* the Source Creation and Management node. Right-click the template and choose T;kh+i
* Open. You can then make changes to the template in the Source Editor. Ktuv
a3=>N
*/
+;@R&Y
ak}ke
package com.tot.count; h _c11#
j*VYUM@y1\
/** |.~2C14[
* $\oe}`#o
* @author B_c-@kl
*/ AA|G&&1y
public class CountBean { 9Z2aFW9
private String countType; ODCN~7-@
int countId; H-&
ktQWK3
/** Creates a new instance of CountData */ xjDaA U,
public CountBean() {} vKbGG
public void setCountType(String countTypes){ :d<F7`k
H
this.countType=countTypes; yF
XPY=EQ
} t]t(/x#
public void setCountId(int countIds){ 'Um\m
this.countId=countIds; <ihJp^kgQ
} r_^]5C\
public String getCountType(){ coXm*X>z
return countType; A8nf"mRD:
} YTe8C9eO
public int getCountId(){ mk-L3H1@J3
return countId; w(%$~]h
} 0a$hK9BH
} gU@.IOg
8(6mH'^y
CountCache.java n?^X/R.22
>Co@K^'
/* rt! lc-g%/
* CountCache.java 7BgA+Fz
* QUdF`_U7
* Created on 2007年1月1日, 下午5:01 :n}t7+(>U
* UD'e%IVw
* To change this template, choose Tools | Options and locate the template under f,+ONV]5Tt
* the Source Creation and Management node. Right-click the template and choose +P*,i$MV
* Open. You can then make changes to the template in the Source Editor. y9GaxW*&