有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Tsu\4
cL]
o@$pyU8
CountBean.java 4%yeEc;z
bB/fU7<{)u
/* {P?p*2J'
* CountData.java AKLFUk
* A]'XC"lS
* Created on 2007年1月1日, 下午4:44 z6qx9x|Ij
* UBnHtsM
* To change this template, choose Tools | Options and locate the template under -idbR[1{?
* the Source Creation and Management node. Right-click the template and choose {v d+cE
* Open. You can then make changes to the template in the Source Editor. 4e[ 0.2?
*/ 1D"EF
BG-nf1K(
package com.tot.count; Wb^g{F!W
PEtr8J$uB
/** hR[_1vuIu
* \@NnL\t
u
* @author }p9#Bzc
*/ "Q.C1#W}.
public class CountBean { &oVZ2.O#(
private String countType; 5Yk|
int countId; 7W/55ZTmJ
/** Creates a new instance of CountData */ ?|<p^:
public CountBean() {}
6l|SGt\
public void setCountType(String countTypes){ L_zB/(h
this.countType=countTypes; NU7k2`bqAk
} gyMy;}a
public void setCountId(int countIds){ Hg(nC*#/Q
this.countId=countIds; kkT=g^D9j
} 6se[>'5
public String getCountType(){ 90Z4saSUw
return countType; 2DBFY1[Pk
} ^S(["6OJ(
public int getCountId(){ 3SF J8
return countId; f1Gyl
} M1Th~W9l
} \T`iq[+6
7I@@}A
CountCache.java +227SPLd
`=W#owAF
/* ]<o^Q[OL
* CountCache.java 2cJ3b
0Xx
* d[e;Fj!
* Created on 2007年1月1日, 下午5:01 Ot!*,%sjQ
* o2riy'~
* To change this template, choose Tools | Options and locate the template under AcY!
* the Source Creation and Management node. Right-click the template and choose % ELf7~
* Open. You can then make changes to the template in the Source Editor. YksJ$yH^
*/ =/^{Pn
X&