⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 homecache.java

📁 源码/软件简介: 云网论坛1.1RC国际版是采用JSP开发的集论坛、CMS(网站内容管理系统)、博客、聊天室、商城、交友、语音灌水等于一体的门户式社区。拥有CWBBS ( Cloud Web BBS
💻 JAVA
字号:
package com.redmoon.forum.miniplugin.home;

import cn.js.fan.base.ObjectCache;
import cn.js.fan.util.StrUtil;
import cn.js.fan.db.PrimaryKey;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2005</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class HomeCache extends ObjectCache {
    final String HOTIDS = "HOTIDS";
    final String RECOMMANDBOARDS = "RECOMMANDBOARDS";
    final String RECOMMANDMSGS = "RECOMMANDMSGS";

    public HomeCache(HomeDb hd) {
        super(hd);
    }

    public void refreshHotIds() {
        try {
            rmCache.remove(HOTIDS);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
    }

    public void refreshRecommandMsgs() {
        try {
            rmCache.remove(RECOMMANDMSGS);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
    }

    public void refreshSave(PrimaryKey pk) {
        removeFromCache(pk);
        refreshHotIds();
        refreshRecommandBoards();
        refreshRecommandMsgs();
    }

    public void refreshRecommandBoards() {
        try {
            rmCache.remove(RECOMMANDBOARDS);
        } catch (Exception e) {
            logger.error(e.getMessage());
        }
    }

    public int[] getHotIds() {
        int[] v = new int[0];
        try {
            v = (int[]) rmCache.get(HOTIDS);
        } catch (Exception e) {
            logger.error(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 {
            HomeDb hd = (HomeDb) objectDb;
            String ids = StrUtil.getNullString(hd.getHot());
            if (!ids.equals("")) {
                ids = ids.replaceAll(",", ",");
                String[] sv = ids.split(",");
                int len = sv.length;
                v = new int[len];
                for (int i = 0; i < len; i++) {
                    v[i] = Integer.parseInt(sv[i]);
                }
                if (v.length > 0) {
                    try {
                        rmCache.put(HOTIDS, v);
                    } catch (Exception e) {
                        logger.error(e.getMessage());
                    }
                }
            }
        }
        if (v == null)
            return new int[0];
        else
            return v;
    }

    public String[] getRecommandBoards() {
        String[] v = new String[0];
        try {
            v = (String[]) rmCache.get(RECOMMANDBOARDS);
        } catch (Exception e) {
            logger.error(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 {
            HomeDb hd = (HomeDb) objectDb;
            String boards = StrUtil.getNullString(hd.getRecommandBoard());
            if (!boards.equals("")) {
                boards = boards.replaceAll(",", ",");
                v = boards.split(",");
                if (v.length > 0) {
                    try {
                        rmCache.put(RECOMMANDBOARDS, v);
                    } catch (Exception e) {
                        logger.error(e.getMessage());
                    }
                }
            }
        }
        if (v == null)
            return new String[0];
        else
            return v;
    }

    public int[] getRecommandMsgs() {
        int[] v = new int[0];
        try {
            v = (int[]) rmCache.get(RECOMMANDMSGS);
        } catch (Exception e) {
            logger.error(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 {
            HomeDb hd = (HomeDb) objectDb;
            String msgIds = StrUtil.getNullString(hd.getRecommandMsg());
            if (!msgIds.equals("")) {
                msgIds = msgIds.replaceAll(",", ",");
                String[] sv = msgIds.split(",");
                int len = sv.length;
                v = new int[len];
                if (len > 0) {
                    for (int i=0; i<len; i++) {
                        v[i] = Integer.parseInt(sv[i]);
                    }
                    try {
                        rmCache.put(RECOMMANDMSGS, v);
                    } catch (Exception e) {
                        logger.error(e.getMessage());
                    }
                }
            }
        }
        if (v == null)
            return new int[0];
        else
            return v;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -