]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Conversation.php
Memcached_DataObject::pkeyGet() accepts null values
[quix0rs-gnu-social.git] / classes / Conversation.php
index f540004ef39b6f9de2c7299ad80fbcd492626aff..e029c20ba0d095145cff147b35aaec6f49d5dd5b 100755 (executable)
@@ -75,5 +75,22 @@ class Conversation extends Memcached_DataObject
         return $conv;
     }
 
-}
+    static function noticeCount($id)
+    {
+        $keypart = sprintf('conversation:notice_count:%d', $id);
+
+        $cnt = self::cacheGet($keypart);
+
+        if ($cnt !== false) {
+            return $cnt;
+        }
 
+        $notice               = new Notice();
+        $notice->conversation = $id;
+        $cnt                  = $notice->count();
+
+        self::cacheSet($keypart, $cnt);
+
+        return $cnt;
+    }
+}