有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: bKMWWJf*'
rVH6QQF=\
CountBean.java KY$k`f6?P
]]TqP{H
/* &vkjmiAS
* CountData.java Vr/Bu4V"
* _A{+H^,
* Created on 2007年1月1日, 下午4:44 hv>KX
* fN)x#?
* To change this template, choose Tools | Options and locate the template under l4vTU=
* the Source Creation and Management node. Right-click the template and choose SO;N~D1Z6
* Open. You can then make changes to the template in the Source Editor. B>z?ClH$R
*/ lpy:3`ti
>;4!O%F
package com.tot.count; dU]/$7
NvJV</l6A
/** I{ ryD -!
* {\G`]r-cM
* @author &gn-Wb?
*/ V}"
g~=
public class CountBean { E!J=8C.:
private String countType; +q{[\#t5
int countId; _c2WqQ-05
/** Creates a new instance of CountData */ raE
Mm
public CountBean() {} ^lj7(
public void setCountType(String countTypes){ KjYAdia:H
this.countType=countTypes; @;iXp>&&
} 5u$ D/*
Eb
public void setCountId(int countIds){ yZCX S
this.countId=countIds; <
Ek/8x
} W.I\J<=V
public String getCountType(){ G.\l qYrXU
return countType; F~HRME;Z
} #%$28sxB
public int getCountId(){ 0;<)\Wt=i9
return countId; v.&>Ih/L
} YoKs:e2/:
} V'G Ju
}%TPYc
CountCache.java ?o*I9[Z)
`~#<&w
/* X~oK[Nf'9
* CountCache.java d2N:^vvvR
* ZnW@YC#9
* Created on 2007年1月1日, 下午5:01 !H@0MQ7
* #Sh <