有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: }h;Z_XF&
3%)cUkD
CountBean.java %Y ZCdS
:g|.x
/* F-3=eKZ
* CountData.java *1dZs~_
* !}*vM@)1
* Created on 2007年1月1日, 下午4:44 1-p#}VX
* SSF:PTeG>
* To change this template, choose Tools | Options and locate the template under t08U9`w
* the Source Creation and Management node. Right-click the template and choose MM32\}Y6
* Open. You can then make changes to the template in the Source Editor. :5~Dca_iU4
*/ UmVn: a
<9pI~\@w
package com.tot.count; IE \RP!
@H?OHpJ"`
/** D=a*Xu2zq
* l\{Qnb(
* @author )W\)kDh!
*/ wnX;eU/n
public class CountBean { viG= Ap.Th
private String countType; .\a+m
int countId; ]x
metv|7
/** Creates a new instance of CountData */ 55O}S Us!P
public CountBean() {} VjWJx^ZL#
public void setCountType(String countTypes){ Hi[lN7ma8
this.countType=countTypes; q<E7qY+
} c/K#W$ l
public void setCountId(int countIds){ HHx:s2G
this.countId=countIds; 6h/!,j0:t_
} l5w^rj
public String getCountType(){ tQzbYzGb7
return countType; @M\JzV4 A[
} C,W@C
public int getCountId(){ j4i$2ZT'
return countId; OG<*&V
} DL,R~
} k H65k (
p_Xfj2E4c
CountCache.java bnfeZR1m_
X{#^O/
/* q,fp
DNo
* CountCache.java HCOsVTl,
* =~O3j:<6
* Created on 2007年1月1日, 下午5:01
n/;{-
* my sXgS&