有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 1#]0\Y(
Gcu[G]D
CountBean.java )1E[CIaXK
QkY]z~P4
/* "#<P--E 9
* CountData.java ^a ,Oi%
* W>^WNo3YQ$
* Created on 2007年1月1日, 下午4:44 kfb*|
* q$#5>5&
* To change this template, choose Tools | Options and locate the template under ]6)~Sj$ 5
* the Source Creation and Management node. Right-click the template and choose 3u&>r-V6Fn
* Open. You can then make changes to the template in the Source Editor. {nr}C4]o
*/ H]zi>;D
whoM$ &
package com.tot.count; S9cAw5E(yN
=x_~7 Xc{
/** /"Z6\T9
* -}_X'h&"
* @author 2b&&3u8
*/ VXfp=JE
public class CountBean { &>jSuvVT
private String countType; u*W6fg/"
int countId; 7,^.h<@K
/** Creates a new instance of CountData */ hN#A3FFo L
public CountBean() {} [wLK*9@&
public void setCountType(String countTypes){ .()|0A B&g
this.countType=countTypes; DK6^\k][V
} 7{"urs7 T
public void setCountId(int countIds){ uT\|jv,
this.countId=countIds; XA1gV>SJ
} f3[/zcm;
public String getCountType(){ 3?n2/p
7=
return countType; per$%;5E"
} NQ9/,M
public int getCountId(){ YA?46[:
return countId; ^9jrI
} Qp?+G~*
} REK(^1
h
e H0^d5bH
CountCache.java WP}NHz4H
_MmSi4]yd
/* QTC-W2t]
* CountCache.java G\PFh&
* .%x1%TN
* Created on 2007年1月1日, 下午5:01 5`3Wua
* 9w"kxAN
* To change this template, choose Tools | Options and locate the template under (X{o =co,
* the Source Creation and Management node. Right-click the template and choose +[lv
`tr
* Open. You can then make changes to the template in the Source Editor. cYeC7l"
*/ =N~*`5|rk
I@M3u/7
package com.tot.count; izvwXC
import java.util.*; 57S!X|CE
/** 9&O7