有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: ^c-
PgtJ3oq[}
CountBean.java <m)$K
D$
dfNiCH
/* Xg|B \\
* CountData.java /:~\5}tW
* 6e9,PS
* Created on 2007年1月1日, 下午4:44 +6HVhoxU#
* MQ5R O;RY
* To change this template, choose Tools | Options and locate the template under T@2#6Tffo
* the Source Creation and Management node. Right-click the template and choose #`CA8!j!!
* Open. You can then make changes to the template in the Source Editor. f$e[u
Er
*/ 7puFz4+f
Dfg2`l
package com.tot.count; X[]m _@ v
G_bG
/** We$:&K0
* n}F&1Z
* @author 3!XjtVhK?I
*/ $q6BP'7
public class CountBean { Dz>^IMsY
private String countType; )h"<\%LU
int countId; 8!O5quEc
/** Creates a new instance of CountData */ Ta
?_5
public CountBean() {} }vxw*8d?
public void setCountType(String countTypes){ ~zCEpU|@N
this.countType=countTypes; iU$] {c2;A
} {.?ZHy\Rk
public void setCountId(int countIds){ *H"B _3<n
this.countId=countIds; cv998*|X:
} Ktb\ b w
public String getCountType(){ >`Y.+4mE
return countType; 5D\f8L
} ?pr9f5
public int getCountId(){ PF)jdcX
return countId; K1mPr^3rC
} `^u>9v-+'
} *6sl
F,W~,y
CountCache.java "-e
\p lKj
G18F&c~
/* nKPYOY8^
* CountCache.java s)noo
* `eE&