有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: K, Vl.-4?
m;|I}{r
CountBean.java %1<|.Dmd
+Y+kx"8
/* H3b`)k
sFr
* CountData.java 7UiU3SUcg
* K} @q+
* Created on 2007年1月1日, 下午4:44 a7ty&[\
* v2^CBKZ+
* To change this template, choose Tools | Options and locate the template under >{[J+f{~|
* the Source Creation and Management node. Right-click the template and choose y[# U/2
* Open. You can then make changes to the template in the Source Editor. Z~
(QV0}
*/ ~EymD *
=6hf'lP
package com.tot.count; +a{>jzR
P^z)]K#sw
/** d4U_Wu&
* -#@;-2w
* @author {Ffr l(*
*/ bk2vce&
public class CountBean { \_oHuw
private String countType; Zv_<*uzKZ
int countId; x$t=6@<]
/** Creates a new instance of CountData */ 8w4.|h5FP
public CountBean() {} +Aq}BjD#
public void setCountType(String countTypes){ te_D
,
this.countType=countTypes; .$rcTZ
} B7
T+a
public void setCountId(int countIds){ W# $rC<Jh]
this.countId=countIds; asb")NfIm
} mi+I)b=
public String getCountType(){ sSxra!tv4
return countType; b@k3y9&
} wcO_;1_
H
public int getCountId(){ 6N^FJCs
return countId; &7cy9Z~m
} z]pH'c39
} MC3{LVNK
y}8j_r
CountCache.java >A6lX)
tO# y4<
/* #Uo
9BM
* CountCache.java <