有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: l@Uo4b^4x
-AWL :<
CountBean.java XDRw![H,~
M:YtW5{
/* fO|oV0Rw
* CountData.java )5Mf,
* [9Q}e;T
* Created on 2007年1月1日, 下午4:44 v2][gn+58
* T*e>_\Tx
* To change this template, choose Tools | Options and locate the template under S3l$\X;6X
* the Source Creation and Management node. Right-click the template and choose bxLeQWr6
* Open. You can then make changes to the template in the Source Editor. )2~Iqzc4
*/ Ev+m+
!N ua
package com.tot.count; 3Uw}!>`%
{a;my"ly
/** JI##l:,7r
* kqdF)Wa am
* @author kwF4I)6
*/ 1w*DU9f
public class CountBean { U 51C /A
private String countType; Q4i@y6z
int countId; ;w--fqxVl
/** Creates a new instance of CountData */ SkU'JM7<95
public CountBean() {} G;Jqby8d
public void setCountType(String countTypes){ ^U OVXRn
this.countType=countTypes; ~?`V$G=?,
} qD0sD2 x
public void setCountId(int countIds){ HE6kt6
this.countId=countIds; f}qR'ognUu
} `tZ m
public String getCountType(){ csABfxib
return countType; ay4E\=k
} %\<SSp^n
public int getCountId(){ x=]PE}<E
return countId; 2?J[D7
} T-S6`^_L
} anxZ|DE
#4?Z|_j3
CountCache.java RHe'L36W
bruM#T@}
/* &