有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: #/9Y}2G|]
9T$%^H9
CountBean.java fpZHE=}r
v^t oe
/* Kx[+$Qt
* CountData.java qKeR}&b
* &{wRB l #
* Created on 2007年1月1日, 下午4:44 mo4F\$2N
* Y>E` 7n
* To change this template, choose Tools | Options and locate the template under zcOm"-E-
* the Source Creation and Management node. Right-click the template and choose ^I6Vz?0Jl
* Open. You can then make changes to the template in the Source Editor. c9nv=?/}f
*/ )FA:wsy~E
FW3E UC)P
package com.tot.count; Xfb-<
Q0A
i8cmT+}>
/** 'tQp&pj
* e<A>??h^
* @author }43qpJe8U
*/ ox.kL
public class CountBean { MR@Qn[RdM
private String countType; 0[uOKFgE
int countId; 9&kPcFX B
/** Creates a new instance of CountData */ ^* y1Fn0
public CountBean() {} 48;b
public void setCountType(String countTypes){ c\szy&W
this.countType=countTypes; #{k+^7aQ
} cj2^wmkB
public void setCountId(int countIds){ 4}0YLwgJ
this.countId=countIds; ]H`pM9rC
} w!d(NA<|0]
public String getCountType(){ !w!k0z]
return countType; %bdBg
} A 3q#,%
public int getCountId(){ !iX/Ni:
return countId; \|]+sQ WQ
} s nNd7v.U6
} 3:sx%Ci/2
@b5$WKPX
CountCache.java a>Aq/=
weGsjy(b]N
/* \7o7~pll
* CountCache.java >G [:Q
s
* %\'G2
* Created on 2007年1月1日, 下午5:01 X$%W&:
* L&|^y8
* To change this template, choose Tools | Options and locate the template under [oXr6M:
* the Source Creation and Management node. Right-click the template and choose @L607[!?
* Open. You can then make changes to the template in the Source Editor. Sq2 8=1%
*/ %l%2 hvGZ
?d3<GhzlR3
package com.tot.count; w&hCt