From: Evan Prodromou Date: Thu, 7 Apr 2011 03:25:24 +0000 (-0400) Subject: cache tags per notice X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d3d0ec5ebe7ac3093569a607cd58f9bbe65a1e28;p=quix0rs-gnu-social.git cache tags per notice --- diff --git a/classes/Notice.php b/classes/Notice.php index 763547a0e1..8e0307b19d 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2004,14 +2004,24 @@ class Notice extends Memcached_DataObject public function getTags() { $tags = array(); - $tag = new Notice_tag(); - $tag->notice_id = $this->id; - if ($tag->find()) { - while ($tag->fetch()) { - $tags[] = $tag->tag; + + $keypart = sprintf('notice:tags:%d', $this->id); + + $tagstr = self::cacheGet($keypart); + + if ($tagstr !== false) { + $tags = explode(',', $tagstr); + } else { + $tag = new Notice_tag(); + $tag->notice_id = $this->id; + if ($tag->find()) { + while ($tag->fetch()) { + $tags[] = $tag->tag; + } } + self::cacheSet($keypart, implode(',', $tags)); } - $tag->free(); + return $tags; }