十鼎 wrote:
andowson wrote:
十鼎 wrote:为主题的文章进行缓存功能,我感觉有问题(我的理解),如果我理解有误还请指教。楼主,你的理解如何?
應該是有問題沒錯,有可能是我誤改了原來的程式碼
trunk/src/main/java/net/jforum/repository/PostRepository.java的118行:
[code=java; first-line:118]posts = pm.selectAllByTopicByLimit(topicId, start, count);[/code]
將其還原為:
[code=java; first-line:118]posts = pm.selectAllByTopic(topicId);[/code]
再測測看吧!
另外,您在發表程式碼時可否幫忙加上code的標籤,以便套用原始碼排版?謝謝您!
可參考這篇的說明:
http://www.andowson.com/posts/list/133.page
旧的设置为:每页主题数15,然后设置为每页10;
在某个版面发表新的主题,直到该版面有12个,当超过10时,页导航出现2页,但是首页主题数为12,次页有2页。
这个问题与上面的问题存在相同的逻辑。
重启服务器后,正常。
问题所在的位置在:net.jforum.view.forum.common.TopicsCommon.java L102。
看来主题缓存和文章缓存都有进一步改进机会。
如您所說的cache機制目前尚需測試來確認是否可正常運作,這個問題可以由修改trunk/src/main/java/net/jforum/view/forum/common/TopicsCommon.java#topicsByForum()來解決:
[code=java;first-line:85]
/**
* List all first 'n' topics of a given forum.
* This method returns no more than <code>ConfigKeys.TOPICS_PER_PAGE</code>
* topics for the forum.
*
* @param forumId The forum id to which the topics belongs to
* @param start The start fetching index
* @return <code>java.util.List</code> containing the topics found.
*/
public static List<Topic> topicsByForum(int forumId, int start)
{
TopicDAO tm = DataAccessDriver.getInstance().newTopicDAO();
int topicsPerPage = SystemGlobals.getIntValue(ConfigKeys.TOPICS_PER_PAGE);
List<Topic> topics;
// Try to get the first's page of topics from the cache
if (SystemGlobals.getBoolValue(ConfigKeys.TOPIC_CACHE_ENABLED)) {
topics = TopicRepository.getTopics(forumId);
if (topics.isEmpty() || !TopicRepository.isLoaded(forumId)) {
synchronized (MUTEXT) {
if (topics.isEmpty() || !TopicRepository.isLoaded(forumId)) {
topics = tm.selectAllByForum(forumId);
TopicRepository.addAll(forumId, topics);
}
}
}
}
else {
topics = tm.selectAllByForumByLimit(forumId, start, topicsPerPage);
}
int size = topics.size();
return topics.subList(start, (size < start + topicsPerPage) ? size : start + topicsPerPage);
}
[/code]
改為topics = tm.selectAllByForum(forumId);
然後return topics.subList(start, (size < start + topicsPerPage) ? size : start + topicsPerPage);