📄 forumcache.java
字号:
package com.redmoon.forum;
import cn.js.fan.base.ObjectCache;
import java.util.Vector;
import cn.js.fan.util.StrUtil;
import cn.js.fan.db.PrimaryKey;
public class ForumCache extends ObjectCache {
final String TOPFORUM = "TOP_FORUM";
final String AD_TOPIC_BOTTOM = "AD_TOPIC_BOTTOM";
final String NOTICE = "FORUM_NOTICE";
public ForumCache(ForumDb forumDb) {
super(forumDb);
}
public void refreshTopMsgs() {
try {
rmCache.remove(TOPFORUM);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
public void refreshSave(PrimaryKey primaryKey) {
super.refreshSave(primaryKey);
try {
rmCache.remove(NOTICE);
rmCache.remove(AD_TOPIC_BOTTOM);
} catch (Exception e) {
logger.error(e.getMessage());
}
}
public Vector getAllNotice() {
Vector v = null;
try {
v = (Vector) rmCache.get(NOTICE);
} catch (Exception e) {
logger.error("getAllNotice:" + e.getMessage());
}
// If already in cache, return the count.
if (v != null) {
return v;
}
// Otherwise, we have to load the count from the db.
else {
String notices = ForumDb.getInstance().getNotices();
notices = notices.replaceAll(",", ",");
String[] ary = StrUtil.split(notices, ",");
v = new Vector();
if (ary!=null) {
int len = ary.length;
if (len > 0) {
try {
MsgMgr mm = new MsgMgr();
for (int i=0; i<len; i++) {
if (StrUtil.isNumeric(ary[i])) {
MsgDb md = mm.getMsgDb(Long.parseLong(ary[i]));
if (md.isLoaded())
v.addElement(md);
}
}
rmCache.put(NOTICE, v);
} catch (Exception e) {
logger.error("getAllNotice:" + e.getMessage());
}
}
}
return v;
}
}
public Vector getAllAdTopicBottom() {
Vector v = null;
try {
v = (Vector) rmCache.get(AD_TOPIC_BOTTOM);
} catch (Exception e) {
logger.error("getAdTopicBottoms:" + e.getMessage());
}
// If already in cache, return the count.
if (v != null) {
return v;
}
// Otherwise, we have to load the count from the db.
else {
String ad = ForumDb.getInstance().getAdTopicBottom();
ad = ad.replaceAll(",", ",");
String[] ary = StrUtil.split(ad, ",");
v = new Vector();
if (ary!=null) {
int len = ary.length;
if (len > 0) {
try {
MsgMgr mm = new MsgMgr();
for (int i=0; i<len; i++) {
if (StrUtil.isNumeric(ary[i])) {
MsgDb md = mm.getMsgDb(Long.parseLong(ary[i]));
if (md.isLoaded())
v.addElement(md);
}
}
rmCache.put(AD_TOPIC_BOTTOM, v);
} catch (Exception e) {
logger.error("getAdTopicBottoms:" + e.getMessage());
}
}
}
return v;
}
}
public long[] getTopMsgs() {
long[] v = new long[0];
try {
v = (long[]) rmCache.get(TOPFORUM);
} catch (Exception e) {
logger.error("getTopMsgs:" + e.getMessage());
}
// If already in cache, return the count.
if (v != null) {
return v;
}
// Otherwise, we have to load the count from the db.
else {
MsgDb md = new MsgDb();
v = md.getTopMsgs();
// Add the thread count to cache
if (v.length > 0) {
try {
rmCache.put(TOPFORUM, v);
} catch (Exception e) {
logger.error("getTopMsgs:" + e.getMessage());
}
}
return v;
}
}
public void setGroup() {
group = "FORUM_";
}
public void setGroupCount() {
COUNT_GROUP_NAME = "FORUM_COUNT_";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -