From: Evan Prodromou Date: Thu, 7 Apr 2011 03:46:51 +0000 (-0400) Subject: cache getReplies() values X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f9dc2fc0ab72200b6069de98ed41828d4d2fb387;p=quix0rs-gnu-social.git cache getReplies() values --- diff --git a/classes/Notice.php b/classes/Notice.php index b948e9de73..6ca4c711fd 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1208,23 +1208,28 @@ class Notice extends Memcached_DataObject */ function getReplies() { - // XXX: cache me + $keypart = sprintf('notice:reply_ids:%d', $this->id); - $ids = array(); + $idstr = self::cacheGet($keypart); - $reply = new Reply(); - $reply->selectAdd(); - $reply->selectAdd('profile_id'); - $reply->notice_id = $this->id; + if ($idstr !== false) { + $ids = explode(',', $idstr); + } else { + $ids = array(); - if ($reply->find()) { - while($reply->fetch()) { - $ids[] = $reply->profile_id; + $reply = new Reply(); + $reply->selectAdd(); + $reply->selectAdd('profile_id'); + $reply->notice_id = $this->id; + + if ($reply->find()) { + while($reply->fetch()) { + $ids[] = $reply->profile_id; + } } + self::cacheSet($keypart, implode(',', $ids)); } - $reply->free(); - return $ids; }