]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
cache tags per notice
authorEvan Prodromou <evan@status.net>
Thu, 7 Apr 2011 03:25:24 +0000 (23:25 -0400)
committerEvan Prodromou <evan@status.net>
Thu, 7 Apr 2011 03:25:24 +0000 (23:25 -0400)
classes/Notice.php

index 763547a0e17ac09487150cac586ba9bd5e8c1f6f..8e0307b19d7730c2ef44059133353c65f2ef965d 100644 (file)
@@ -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;
     }