类似
http://wenda.wecenter.com/topic/channel-topic__topic_id-765 页面
正常情况下,此页只会返回20条数据
如果非正常访问,如
http://wenda.wecenter.com/topic/channel-topic__topic_id-0
在没有缓存的情况下,会返回全部topic数据,会单次查询上千个topic_id(因此,每次缓存过期,重新访问此页时,都会卡一会)
建议修改方法:修改 app/topic/main.php
将
case 'topic':
if (!$topics_list = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']))) {
$topic_ids = intval($_GET['topic_id']);
if ($child_topic_ids = $this->model('topic')->get_child_topic_ids($_GET['topic_id'])) {
$topic_ids = array_merge($child_topic_ids, $topic_ids);
}
if ($topics_list = $this->model('topic')->get_topic_list('topic_id IN(' . implode(',', $topic_ids) . ') AND merged_id = 0', 'discuss_count DESC', 20, $_GET['page'])) {
$topics_list_total_rows = $this->model('topic')->found_rows();
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
}
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
} else {
$topics_list_total_rows = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows');
}
TPL::assign('topics_list', $topics_list);
break;
改为
case 'topic':
if (!$topics_list = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']))) {
$_GET['topic_id'] = intval($_GET['topic_id']);
$_GET['page'] = intval($_GET['page']);
$topics_list = $this->model('topic')->fetch_page('topic', 'merged_id = 0 AND parent_id = ' . intval($_GET['topic_id']), 'discuss_count DESC', $_GET['page'], 20);
$topics_list_total_rows = $this->model('topic')->found_rows();
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_' . intval($_GET['page']), $topics_list, get_setting('cache_level_low'));
AWS_APP::cache()->set('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows', $topics_list_total_rows, get_setting('cache_level_low'));
} else {
$topics_list_total_rows = AWS_APP::cache()->get('square_parent_topics_topic_list_' . intval($_GET['topic_id']) . '_total_rows');
}
TPL::assign('topics_list', $topics_list);
break;
}
阅读全文
收起全文