git.gnu.io has moved to IP address 209.51.188.249 -- please double check where you are logging in.

Commit 59d0e2f3 authored by Evan Prodromou's avatar Evan Prodromou

cache the notice count for threaded view

parent 68b1c057
......@@ -74,4 +74,23 @@ class Conversation extends Memcached_DataObject
return $conv;
}
static function noticeCount($id)
{
$keypart = sprintf('conversation:notice_count:%d', $id);
$cnt = self::cacheGet($keypart);
if ($cnt !== false) {
return $cnt;
}
$notice = new Notice();
$notice->conversation = $id;
$cnt = $notice->count();
self::cacheSet($keypart, $cnt);
return $cnt;
}
}
......@@ -567,6 +567,7 @@ class Notice extends Memcached_DataObject
// was not the root of the conversation. What to do now?
self::blow('notice:conversation_ids:%d', $this->conversation);
self::blow('conversation::notice_count:%d', $this->conversation);
if (!empty($this->repeat_of)) {
self::blow('notice:repeats:%d', $this->repeat_of);
......
......@@ -284,9 +284,8 @@ class ThreadedNoticeListMoreItem extends NoticeListItem
$id = $this->notice->conversation;
$url = common_local_url('conversationreplies', array('id' => $id));
$notice = new Notice();
$notice->conversation = $id;
$n = $notice->count() - 1;
$n = Conversation::noticeCount($id) - 1;
// TRANS: Link to show replies for a notice.
// TRANS: %d is the number of replies to a notice and used for plural.
$msg = sprintf(_m('Show reply', 'Show all %d replies', $n), $n);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment