有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: lIx./Nf
XHdhSFpm
CountBean.java oD9L5c)
5}w
/* z%T|L[(6
* CountData.java |v :
)9
* 34"PtWbV>
* Created on 2007年1月1日, 下午4:44 '/X]96Ci7
* z$~F9Es9
* To change this template, choose Tools | Options and locate the template under %I!2dXNFRF
* the Source Creation and Management node. Right-click the template and choose @x743}Y\
* Open. You can then make changes to the template in the Source Editor. X6(s][Wn
*/ D *PEIsV
1ZRkVHiz0
package com.tot.count; Z^'\()3t
#pK"
^O*!
/** u3,O)[qV
* %yjD<2J;
* @author Y.tT#J^=
*/ uPYH3<
public class CountBean { [.Kp/,JY
private String countType; )u=W?5%=}
int countId; u-:3C<&>
/** Creates a new instance of CountData */ XpE847!soL
public CountBean() {} kQ lwl9
public void setCountType(String countTypes){ [Y@>,B!V
this.countType=countTypes; :{lP9%J-
} >}O}~$o
public void setCountId(int countIds){ [2Nux0g
this.countId=countIds; '6>*J
} &(32s! qH
public String getCountType(){ >zL5*:G
return countType; b.\xPb
} <Up?w/9
public int getCountId(){ r;[ =y<Yf
return countId; ysp`(n=
} w7Y@wa!
} Sx e6&
u-4@[*^T$
CountCache.java yzzJKucVU:
a\}MJ5]
/* 8,!Oup
* CountCache.java 6},[HpXRc4
* | Rhqi
* Created on 2007年1月1日, 下午5:01 ]Zc|<f;
* Q3&q%n|<
* To change this template, choose Tools | Options and locate the template under e3 :L]4t
* the Source Creation and Management node. Right-click the template and choose ykPiZK
* Open. You can then make changes to the template in the Source Editor. "opMS/a"7
*/ fCJjFL:
0NC70+4L
package com.tot.count; v*=P
import java.util.*; (?JdiY/
/** b"N!#&O