有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ]RI+:f
14 hE<u
CountBean.java Sh U1RQk
zW ; sr.
/* pJ@D}2u(
* CountData.java '!XVz$C
* oMb@)7
* Created on 2007年1月1日, 下午4:44 kfs[*ku
* Uj)`(}r
* To change this template, choose Tools | Options and locate the template under 5oY^;)\/
* the Source Creation and Management node. Right-click the template and choose K!|J/W
* Open. You can then make changes to the template in the Source Editor. =D^R,Q
*/ J+Zp<Wu-
z7O$o/E-*
package com.tot.count; AbOF/g)C
-pm%F8{T]
/** >+ku:<Hw%.
* [Pz['q L3t
* @author vqJq=\ .m
*/ }m.45n/
public class CountBean { >B+!fi'SS>
private String countType; B5/"2i
int countId; %_ Vj'z~T
/** Creates a new instance of CountData */ 0-IL@Di`F
public CountBean() {} D'\gy$9m1
public void setCountType(String countTypes){ ]9$^=z%SE
this.countType=countTypes;
o+FDkqEN
} WKONK;U+7
public void setCountId(int countIds){ }Gh95HwE
this.countId=countIds; -h,?_d>
} Y/,Cy0!
public String getCountType(){ N9BfjT}
return countType; ee
.,D
} !,cfA';S
public int getCountId(){ ?%i~~hfH#N
return countId; L-Pq/x2r
} t'bhA20Z\
} ~>>^7oq
7) Qq
CountCache.java :$&