From d3d0ec5ebe7ac3093569a607cd58f9bbe65a1e28 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 6 Apr 2011 23:25:24 -0400 Subject: [PATCH] cache tags per notice --- classes/Notice.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) 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; } -- 2.39.5