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;
+ }
}
// 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);
$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);