]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
cache generated activity info
authorEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 21:38:02 +0000 (16:38 -0500)
committerEvan Prodromou <evan@status.net>
Mon, 6 Dec 2010 21:38:02 +0000 (16:38 -0500)
classes/Notice.php
lib/activity.php

index de5104fdbba3ff3018e42241d784d75b72aa001a..46e1dca35e57f87022a2aab3230c53aa7a2b10e1 100644 (file)
@@ -1236,10 +1236,16 @@ class Notice extends Memcached_DataObject
 
     function asActivity($cur = null, $source = false)
     {
+        $act = self::cacheGet('notice:as-activity:'.$this->id);
+
+        if (!empty($act)) {
+            return $act;
+        }
+
         $act = new Activity();
        
         if (Event::handle('StartNoticeAsActivity', array($this, &$act))) {
-           
+
             $profile = $this->getProfile();
            
             $act->actor     = ActivityObject::fromProfile($profile);
@@ -1400,6 +1406,8 @@ class Notice extends Memcached_DataObject
             Event::handle('EndNoticeAsActivity', array($this, &$act));
         }
        
+        self::cacheSet('notice:as-activity:'.$this->id, $act);
+
         return $act;
     }
 
index e29bc1a25da093b812bcf28beb194e19ca0b3e4b..712800817c71351d6ff7806b3efb934cbc52d3da 100644 (file)
@@ -329,6 +329,14 @@ class Activity
 
     function asString($namespace=false, $author=true)
     {
+        $c = Cache::instance();
+
+        $str = $c->get('activity:as-string:'.Cache::keyize($this->id));
+
+        if (!empty($str)) {
+            return $str;
+        }
+
         $xs = new XMLStringer(true);
 
         if ($namespace) {
@@ -549,7 +557,11 @@ class Activity
 
         $xs->elementEnd('entry');
 
-        return $xs->getString();
+        $str = $xs->getString();
+       
+        $c->set('activity:as-string:'.Cache::keyize($this->id), $str);
+       
+        return $str;
     }
 
     private function _child($element, $tag, $namespace=self::SPEC)