有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: u2 a#qU5*
Bz+zEXBC
CountBean.java NB^+Hcb$
|&49YQ
/* 7$zeRYD+
* CountData.java ?zP/i(1y
* s;!_'1pi@
* Created on 2007年1月1日, 下午4:44 .91@T.
* |d)*,O4s
* To change this template, choose Tools | Options and locate the template under $S6%a9m
* the Source Creation and Management node. Right-click the template and choose T1~G{@"
* Open. You can then make changes to the template in the Source Editor. iZ( U]
*/ zBjtPtiiI8
3xX^pjk
package com.tot.count; U0J_
3W
]I^b&N
/** v?
Ufx
* Q1[3C(
* @author 0d|DIT#>?
*/ ]. E/s(p
public class CountBean { \?_M_5Nb
private String countType; 8\BGL
int countId; 2 ":W^P
/** Creates a new instance of CountData */ %
|^V)
public CountBean() {} nl)l:A+q8
public void setCountType(String countTypes){ nRHxbE}::
this.countType=countTypes; t6C2DHh7$
} X/BcS[a
public void setCountId(int countIds){ Z#NEa.]
this.countId=countIds; <p5?yF
} Kl/n>qEt
public String getCountType(){ =nff;Xu
return countType; Y
a/+|mv
} KD* xFap
public int getCountId(){ YAP,#a
return countId; vq` M]1]FO
} <ebC]2j8cK
} 3j7Na#<tL3
:\F1S:&P
CountCache.java wLa8&E