有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: r,3\32[?
?D,j!Hy
CountBean.java c[V.j+Iy#^
]rSg,Q>E
/* YNl".c
* CountData.java K-"`A.:S
* ;at1|E*
* Created on 2007年1月1日, 下午4:44 obN8+ j
* Wsp c;]&
* To change this template, choose Tools | Options and locate the template under |3~]XN-
* the Source Creation and Management node. Right-click the template and choose 7z$bCO L=S
* Open. You can then make changes to the template in the Source Editor. %iME[| u&
*/ :yE0DS<_
&*E! %57
package com.tot.count; cL!A,+S[_
u\MxQIo'u
/** Jamt@=
* ho)JY
$#6
* @author WJ)4rQ$o
*/ .LDp.#d9r1
public class CountBean { LitdO>%#2
private String countType; ..k8HFz>"
int countId; Kv:Rvo
/** Creates a new instance of CountData */ +sTPTCLE
public CountBean() {} a\~118 !
public void setCountType(String countTypes){ yye5GVY$
this.countType=countTypes; !Eb|AHa
} ? HNuffk
public void setCountId(int countIds){ `>b,'u6F
this.countId=countIds; Qg]A^{.1
} !G6h~`[
public String getCountType(){ ,j9? 9Z7R
return countType; ._t1eb`m{
} {-MjsBR
public int getCountId(){ fFoZ!H
return countId; `KE]RTq
} m>F:dI
} -/0aGqY
n(|n=P:o
CountCache.java ZR-64G=L,
4.uaWM)2
/* e2K9CE.O
* CountCache.java &c