📄 homecache.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;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 (v != null) { return v; } 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 (v != null) { return v; } 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 (v != null) { return v; } 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 + -