有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ~;yP{F8?
]h?p3T$h
CountBean.java N^%7
o+F<
r#
/* 5LzP0F
U
* CountData.java aM|;3j1p
* pFcCe
'd"
* Created on 2007年1月1日, 下午4:44 DLd1Cl:"~:
* mY&(&'2T"
* To change this template, choose Tools | Options and locate the template under +MyXIWmD
* the Source Creation and Management node. Right-click the template and choose # "!q_@b,D
* Open. You can then make changes to the template in the Source Editor. m*~Iu<5L
*/ xL$7bw5fY
c|<E~_.w@
package com.tot.count; f7?IXDQ>!
D2]i*gs
/** dZ`c
* _p;=]#+c&
* @author `%Dz 8Z
*/ 8C8,Q\WV(~
public class CountBean { <3!Q Xc
private String countType; tO+Lf2Ni+
int countId; ].HHTCD`c
/** Creates a new instance of CountData */ D8f4X
w}=
public CountBean() {} si#1sdR
public void setCountType(String countTypes){ D|D)782
this.countType=countTypes; >b2wFo/em
} S(PU"}vZy
public void setCountId(int countIds){ Qm>2,={h
this.countId=countIds; ,*CPG$L
} `&URd&ouJD
public String getCountType(){ .>
5[;
return countType; GBYwS{4
} DC(u,iW%6
public int getCountId(){
B6.9hf
return countId; \k.W
F|~
} vJ{aBx`VS
} h?P-
:E
+'{d^-( (
CountCache.java GUC.t7!
^T*'B-`C7X
/* {'z(
* CountCache.java |vtj0,[
* RX?y}BDo0
* Created on 2007年1月1日, 下午5:01 G_S2Q @|Q
* OBL2W\{
* To change this template, choose Tools | Options and locate the template under <