有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: :Ye~I;"8
#v4^,$k>
CountBean.java 2#8PM-3"
T0 cm+|S
/* D\E"v,Y\+O
* CountData.java ~/Y8wxg
* '1zC|:,
* Created on 2007年1月1日, 下午4:44 }:*?w>=
* Xd.y or
* To change this template, choose Tools | Options and locate the template under COd~H
* the Source Creation and Management node. Right-click the template and choose -L2?Tap
* Open. You can then make changes to the template in the Source Editor.
U^-RyE!}
*/ r
l;Y7l
COD^osM@
package com.tot.count; 2\gbciJ[{(
(~(FQ:L%U
/** 5Gz~,_
* a;(,$q3M
* @author ^}kYJvqA
*/
-:wV3D
public class CountBean { Vkqfs4 t
private String countType; \2Kl]G(w%y
int countId; aw7pr464
/** Creates a new instance of CountData */ {@s6ly].
public CountBean() {} $>Gf;k
public void setCountType(String countTypes){ [3qJUJM
this.countType=countTypes; >f;oY9 {m
} lxBcO/
public void setCountId(int countIds){ |r4&@)
this.countId=countIds; ,pW^>J
} VotI5O $
public String getCountType(){ \;+b1
return countType; (D+%*ax
} S Z &[o&H
public int getCountId(){ Rb
<{o8
return countId; , _ xJ9_
} T <RWz
} Iapzh y2l
>_X(rar0
CountCache.java wHQYBYKcd
7K!n'dAi6
/* HBw0N?
* CountCache.java }~#qDrK
* 7/\SN04l
* Created on 2007年1月1日, 下午5:01 / $'M
* ])WIw'L!
* To change this template, choose Tools | Options and locate the template under RC!T1o~L
* the Source Creation and Management node. Right-click the template and choose 6X$\:>
* Open. You can then make changes to the template in the Source Editor. u7-0?
*/ 5jTA6s9z A
[U7r>&