有时要为每一篇文章统计其点击次数,如果每一次浏览都要更新一次库的话,那性能在访问量很大的情况下,服务器的压力就会很大了,比较好一点的方法就是先将要更新的数据缓存起来,然后每隔一段时间再利用数据库的批量处理,批量更新库。源码如下: 2UiR~P]%
e9&+vsRmA
CountBean.java 62Mdm3
</= CZy5w
/* 5y]io
Jc9-
* CountData.java >-M ]:=L
* #b'N}2'p#V
* Created on 2007年1月1日, 下午4:44 %,/lqc Fo
* N>0LQ
MI
* To change this template, choose Tools | Options and locate the template under jo}1u_OJ
* the Source Creation and Management node. Right-click the template and choose -ey)J
+?t
* Open. You can then make changes to the template in the Source Editor. TjxA#D)
*/ qe?Qeh(!X
+Gow5-(
package com.tot.count;
g5i#YW
[]zua14F6
/** 8'_ 0g[s
* !siWEzw
* @author <?YA,"~
*/ 9t?L\
public class CountBean { _-O cc=Z
private String countType; `?"6l5d.]
int countId; B8 H75sz
/** Creates a new instance of CountData */ YGp)Oy}:
public CountBean() {} \7Qb229?
public void setCountType(String countTypes){ b0rX QMu
this.countType=countTypes; )s)_XL
} =LI:S|[4
public void setCountId(int countIds){ |f\D>Y%)
this.countId=countIds; _1aGtX|W
} <J&7]6Z
public String getCountType(){ D^+?|Y@N
return countType; <*<U!J-i
} z}+i=cAN
public int getCountId(){ RP!
X8~8
return countId; )u*^@Wo
} id ?"PD"%
} *)'V vu<
[k$efwJ
CountCache.java oZN'HT
_7"5wB?|+
/* /aY pIMi9}
* CountCache.java 8.QSqW7t
* L&kr