有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: />V&
OX`
cA B<'44R
CountBean.java NoT%z$1n
Dn+hI_"#_
/* >]ZW.?1h
* CountData.java u Qz!of%x
* 1F{,Zr
* Created on 2007年1月1日, 下午4:44 ;~( yv|f6
* ]eo%eaA
* To change this template, choose Tools | Options and locate the template under >4nQ&b.u
* the Source Creation and Management node. Right-click the template and choose B;J8^esypD
* Open. You can then make changes to the template in the Source Editor. J(Zz^$8]<?
*/ }KR"0G[f
4Xe8j55
package com.tot.count; iB5'mb*
WO[O0!X
/** Uh3N#O
* 6-f-/$B
* @author 1i;#cIG
*/ X1^Q1?0
public class CountBean { B1b9
JS(>
private String countType; M,oRi;V
int countId; C{]1+eL
/** Creates a new instance of CountData */ KDLrt
public CountBean() {} O+ xzM[[
public void setCountType(String countTypes){ PySFhb@
this.countType=countTypes; yMJ(Sf
} =!DpW VsQ
public void setCountId(int countIds){ mQ^SpK #
this.countId=countIds; xtzkgb,0[
} U i`#B
public String getCountType(){ P5&8^YV`N
return countType; {ukQBu#}<
} !twYjOryH[
public int getCountId(){ il$eO 7
return countId; |P7FPmn
} =JN{j2xY
} %;b] k
wnHfjF
CountCache.java aA'of>'ib|
;e6-*
/* __`6 W1
* CountCache.java 5>aK4: S/
* deCi\n
* Created on 2007年1月1日, 下午5:01 EAK[2?CY
* zB'_YwW
* To change this template, choose Tools | Options and locate the template under Koc5~qUY]
* the Source Creation and Management node. Right-click the template and choose Dfy=$:Q
* Open. You can then make changes to the template in the Source Editor. 5'n$aFqI
*/ VI?kbqjo
"&@{f:+
package com.tot.count; nRs:^Q~o
import java.util.*; M[ ON2P;
/** aq- |
* x pBQ(6Y
* @author q$'[&&