]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
method to count notices linking to an URL
authorEvan Prodromou <evan@status.net>
Tue, 28 Dec 2010 21:44:49 +0000 (13:44 -0800)
committerEvan Prodromou <evan@status.net>
Tue, 28 Dec 2010 21:44:49 +0000 (13:44 -0800)
classes/File.php

index 2b0e636c164f7c2372a6688eb246a5f96eb8b988..29a8f0f1c5a16cc8661196c7d23a2d6787d4ac22 100644 (file)
@@ -427,6 +427,7 @@ class File extends Memcached_DataObject
         if ($last) {
             self::blow('file:notice-ids:%s;last', $this->url);
         }
+        self::blow('file:notice-count:%d', $this->id);
     }
 
     /**
@@ -489,4 +490,24 @@ class File extends Memcached_DataObject
 
         return $ids;
     }
+
+    function noticeCount()
+    {
+        $cacheKey = sprintf('file:notice-count:%d', $this->id);
+        
+        $count = self::cacheGet($cacheKey);
+
+        if ($count === false) {
+
+            $f2p = new File_to_post();
+
+            $f2p->file_id = $this->id;
+
+            $count = $f2p->count();
+
+            self::cacheSet($cacheKey, $count);
+        } 
+
+        return $count;
+    }
 }