有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ohs`[U=%~
ox_DEg7l
CountBean.java R"l6|9tmP
B_D0yhh
/* zeq")A
* CountData.java @n=&muC}
* oW(EV4J"
* Created on 2007年1月1日, 下午4:44 `$XB_o%@
* +
)z5ai0m
* To change this template, choose Tools | Options and locate the template under X|&H2y|*7
* the Source Creation and Management node. Right-click the template and choose YWJ$Pp
* Open. You can then make changes to the template in the Source Editor. "ZPgl 8
*/ 0FLCN!i1
V(:wYk?ZR
package com.tot.count; 22;B:
+o'xyR'(
/** 9_4(}|"N|
* :pNS$g[
* @author cucmn*o?
*/ V7`vLs-
public class CountBean { L8H:,} 2
private String countType; 1wH6 hN,
int countId; 2h#.:!/SMw
/** Creates a new instance of CountData */ T1R~^x1
public CountBean() {} IuA4eDr^Y%
public void setCountType(String countTypes){ OnhR`
this.countType=countTypes; mU
} 3ZI:EZ5
public void setCountId(int countIds){ "shX~zd5
this.countId=countIds; WnOvU<Z
<
} 'Z:wEt!
public String getCountType(){ J"@X>n
return countType; ';!-a]N
} }p-/R'
public int getCountId(){ :>Bk^"
return countId; ZJ~0o2xZ'
} .z=%3p8+
} TvS<;0~K
q317~z_nl
CountCache.java M,X)rM}Q
V#|/\-@
/* G Y.iCub
* CountCache.java &