有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: +|8.ymvm
8y_(Iu|:
CountBean.java c9Cc%EK
xx7&y!_
/* =5fY3%^b{
* CountData.java YO?o$Hv16
* :sLg$OF
* Created on 2007年1月1日, 下午4:44 x>BFK@#
* )b=vBs`%
* To change this template, choose Tools | Options and locate the template under s6(md<r
* the Source Creation and Management node. Right-click the template and choose _/cX!/"
* Open. You can then make changes to the template in the Source Editor. O'#;Ge/,
*/ 4${3e
Sg_
LikCIO
package com.tot.count; matm>3n
Z1+Ewq3m
/** O{7#Xj
:_
* 3vAP&i'I
* @author <gH-`3J6
*/ 0pW;H|h
public class CountBean { ]GCw3r(!
private String countType; 1|ddG010
int countId; YPq:z"`-y4
/** Creates a new instance of CountData */ .V0fbHYTJ
public CountBean() {} G?\eO&QG{"
public void setCountType(String countTypes){ Ex*{iJ;\
this.countType=countTypes; {}iS5[H]
} u8|CeA
public void setCountId(int countIds){ I?%q`GyP5
this.countId=countIds; }aXS MxCd
} ,WnZ^R/n
public String getCountType(){ '/9MN;_
return countType; wxj}k7_(`A
} QfPw50N;
public int getCountId(){ g+QIhur
return countId; zw$\d1-+h
} B1E:P`t
} ; !t?*
^J^FGo|M
CountCache.java G973n
*14:^neoI
/* #DJZ42
* CountCache.java T<Qa`|5>
* v''J@ F7
* Created on 2007年1月1日, 下午5:01 B~qo^ppVU
* i!3*)-a\~`
* To change this template, choose Tools | Options and locate the template under \ISg6v{/
* the Source Creation and Management node. Right-click the template and choose Le bc@,
* Open. You can then make changes to the template in the Source Editor. r)Zk- !1
*/ `/N={
t:P]bp^#
package com.tot.count; uW/>c$*)
import java.util.*; C0Fd<