forumcachewarmuptask.java
来自「Jive是基于JSP/JAVA技术构架的一个大型BBS论坛系统,这是Jive论坛」· Java 代码 · 共 67 行
JAVA
67 行
/** * $RCSfile: ForumCacheWarmupTask.java,v $ * $Revision: 1.4 $ * $Date: 2002/07/12 05:56:36 $ * * Copyright (C) 1999-2001 CoolServlets, Inc. All rights reserved. * * This software is the proprietary information of CoolServlets, Inc. * Use is subject to license terms. */package com.jivesoftware.forum.database;import com.jivesoftware.forum.*;import java.util.*;/** * A task that warms up the cache of a forum by loading up chunks of its thread * and message data. */public class ForumCacheWarmupTask implements Runnable { private static ResultFilter filter; static { filter = ResultFilter.createDefaultThreadFilter(); filter.setNumResults(DbForum.BLOCK_SIZE); } private Forum forum; /** * Create a new cache warmup task. The forum that should have its cache * warmed up must be specified. * * @param forum the forum to do cache warmup on. */ public ForumCacheWarmupTask(Forum forum) { super(); this.forum = forum; } public void run() { forum.getMessageCount(); // Load 1/3rd the threads in the forum up to a max of 1500. int maxTCount = forum.getThreadCount(); if (maxTCount != 0) { maxTCount /= 3; maxTCount = Math.min(maxTCount, 1000); } int tCount = 0; for(Iterator i=forum.threads(); i.hasNext() && tCount < maxTCount ; tCount++) { ForumThread thread = (ForumThread)i.next(); // Load 1/2 the messages in each thread up to a max of 200. int maxMCount = thread.getMessageCount(); if (maxMCount != 0) { maxMCount /= 2; maxMCount = Math.min(maxMCount, 100); } int mCount = 0; for(Iterator j=thread.messages(); j.hasNext() && mCount < maxMCount; mCount++) { ForumMessage message = (ForumMessage)j.next(); // Load the author of the message. message.getUser(); } } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?