blogcache.java
来自「cwbbs 云网论坛源码」· Java 代码 · 共 603 行 · 第 1/2 页
JAVA
603 行
} else { Conn conn = new Conn(connname); ResultSet rs = null; try { conn.setMaxRows(n); rs = conn.executeQuery(sql); conn.setFetchSize(n); v = new long[conn.getRows()]; int i = 0; while (rs.next()) { v[i] = rs.getLong(1); i++; } } catch (SQLException e) { logger.error("getPostRank:" + e.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (Exception e) { e.printStackTrace(); } rs = null; } if (conn != null) { conn.close(); conn = null; } } if (v.length > 0) { try { rmCache.putInGroup(REPLYRANKBLOG, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } return v; } } public long[] getNewBlogs(int n) { String sql = "select id from blog_user_config order by addDate desc"; long[] v = null; try { v = (long[]) rmCache.getFromGroup(NEWBLOG, group); } catch (Exception e) { logger.error("getNewBlogs:" + e.getMessage()); } if (v != null) { return v; } else { Conn conn = new Conn(connname); ResultSet rs = null; try { conn.setMaxRows(n); rs = conn.executeQuery(sql); conn.setFetchSize(n); v = new long[conn.getRows()]; int i = 0; while (rs.next()) { v[i] = rs.getLong(1); i++; } } catch (SQLException e) { logger.error("getNewBlogs:" + e.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (Exception e) { e.printStackTrace(); } rs = null; } if (conn != null) { conn.close(); conn = null; } } if (v.length > 0) { try { rmCache.putInGroup(NEWBLOG, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } return v; } } public long[] getNewUpdateBlogs(int n) { String sql = "select id from blog_user_config order by update_date desc"; long[] v = null; try { v = (long[]) rmCache.getFromGroup(NEWUPDATEBLOG, group); } catch (Exception e) { logger.error("getNewUpdateBlogs:" + e.getMessage()); } if (v != null) { return v; } else { Conn conn = new Conn(connname); ResultSet rs = null; try { conn.setMaxRows(n); rs = conn.executeQuery(sql); conn.setFetchSize(n); v = new long[conn.getRows()]; int i = 0; while (rs.next()) { v[i] = rs.getLong(1); i++; } } catch (SQLException e) { logger.error("getNewUpdateBlogs:" + e.getMessage()); } finally { if (rs != null) { try { rs.close(); } catch (Exception e) { e.printStackTrace(); } rs = null; } if (conn != null) { conn.close(); conn = null; } } if (v.length > 0) { try { rmCache.putInGroup(NEWUPDATEBLOG, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } return v; } } public String[] getCommendBlogs(int n) { String sql = "select userName from blog_user_config order by viewcount desc"; String[] v = new String[0]; try { v = (String[]) rmCache.getFromGroup(COMMENDBLOG, group); } catch (Exception e) { logger.error("getNewBlogs:" + e.getMessage()); } if (v != null) { return v; } else { Conn conn = new Conn(connname); ResultSet rs = null; try { conn.setMaxRows(n); rs = conn.executeQuery(sql); conn.setFetchSize(n); v = new String[conn.getRows()]; String userName; int i = 0; while (rs.next()) { userName = rs.getString(1); v[i] = userName; i++; } } catch (SQLException e) { logger.error("getNewBlogs:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } if (v.length > 0) { try { rmCache.putInGroup(NEWBLOG, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } return v; } } public long[] getBlogMsgsOfKind(int n, String kind) { long[] v = null; String sql = "select id from sq_thread where check_status=" + MsgDb.CHECK_STATUS_PASS + " and isBlog=1 and blog_dir_code=" + StrUtil.sqlstr(kind) + " order by lydate desc"; try { v = (long[]) rmCache.getFromGroup(sql, group); } catch (Exception e) { logger.error("getTopBlogs:" + e.getMessage()); } if (v != null) { return v; } else { Conn conn = new Conn(connname); ResultSet rs = null; try { conn.setMaxRows(n); rs = conn.executeQuery(sql); conn.setFetchSize(n); v = new long[conn.getRows()]; int id; int i = 0; while (rs.next()) { id = rs.getInt(1); v[i] = id; i++; } } catch (SQLException e) { logger.error("getBlogMsgsOfKind:" + e.getMessage()); } finally { if (conn != null) { conn.close(); conn = null; } } if (v.length > 0) { try { rmCache.putInGroup(sql, group, v); } catch (Exception e) { logger.error(e.getMessage()); } } return v; } } public void setGroup() { group = "BLOG_"; } public void setGroupCount() { COUNT_GROUP_NAME = "BLOG_COUNT_"; } public void regist() { if (!isRegisted) { rmCache.regist(this); isRegisted = true; } } public void timer() { curHomeRefreshLife--; if (curHomeRefreshLife <= 0) { refreshHomePage(); curHomeRefreshLife = BLOG_HOME_REFRESH_INTERVAL; } } public static long BLOG_HOME_REFRESH_INTERVAL = Config.getInstance().getIntProperty("homeRefreshInterval"); private long curHomeRefreshLife = BLOG_HOME_REFRESH_INTERVAL; static boolean isRegisted = false;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?