有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: Nh7Dz
Fb#_(I[aj
CountBean.java x!CCSM;q
"S6'<~s
/* ^l\U6$3
* CountData.java [a~|{~?8
* ]Bo !v*12
* Created on 2007年1月1日, 下午4:44 |2mm@):
* jkd'2
* To change this template, choose Tools | Options and locate the template under j6wdqa9!~
* the Source Creation and Management node. Right-click the template and choose C(i1 Vx<-
* Open. You can then make changes to the template in the Source Editor. 96fzSZS,
*/ D[)
Z$+D4f
--SlxV/x
package com.tot.count; M7R.?nk
M1><K:
/** T/NeoU3 p
* `usX(snY
* @author 1`1U'ibhe
*/ =5bef8 O
public class CountBean { E?>
ERO3
private String countType;
6C6<,c
int countId; ;0lHi4 c0
/** Creates a new instance of CountData */ $ZSjq
public CountBean() {} _hgu:
public void setCountType(String countTypes){ (UWV#AR
this.countType=countTypes; 0Da9,&D
} p<#WueR[
public void setCountId(int countIds){ m,i@
this.countId=countIds; Q/EHvb]
} &)?ECj0`
public String getCountType(){ .W_'6Q+
return countType; s!*m^zx
} qV^Z@N+,
public int getCountId(){ x9UF
return countId; QXTl'.SfF
} LadE4:oy
} APydZ
{DzOXTI[Y
CountCache.java .!yXto:
4-RzWSFbo`
/* r(g:b
^S
* CountCache.java e nsou!l
* qx,>j4yw
* Created on 2007年1月1日, 下午5:01 @edx]H1~^
* #bN'N@|
* To change this template, choose Tools | Options and locate the template under 49vKb(bz{
* the Source Creation and Management node. Right-click the template and choose ~ ;CnwG
* Open. You can then make changes to the template in the Source Editor. <