]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Caching fixes for Fave class
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 1 Jul 2014 20:13:11 +0000 (22:13 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 2 Jul 2014 09:38:51 +0000 (11:38 +0200)
plugins/Favorite/classes/Fave.php

index 777f3a362a12f00db5757b9624203f3ee822bc8b..089cafc884e5edd9693a2a3560543368bfad6bd8 100644 (file)
@@ -69,7 +69,8 @@ class Fave extends Managed_DataObject
                 common_log_db_error($fave, 'INSERT', __FILE__);
                 return false;
             }
-            self::blow('fave:list-ids:notice_id:%d', $fave->notice_id);
+            self::blowCacheForProfileId($fave->user_id);
+            self::blowCacheForNoticeId($fave->notice_id);
             self::blow('popular');
 
             Event::handle('EndFavorNotice', array($profile, $notice));
@@ -88,7 +89,9 @@ class Fave extends Managed_DataObject
         if (Event::handle('StartDisfavorNotice', array($profile, $notice, &$result))) {
 
             $result = parent::delete($useWhere);
-            self::blow('fave:list-ids:notice_id:%d', $this->notice_id);
+
+            self::blowCacheForProfileId($this->user_id);
+            self::blowCacheForNoticeId($this->notice_id);
             self::blow('popular');
 
             if ($result) {
@@ -266,4 +269,11 @@ class Fave extends Managed_DataObject
             $cache->delete(Cache::key('fave:count_by_profile:'.$profile_id));
         }
     }
+    static public function blowCacheForNoticeId($notice_id)
+    {
+        $cache = Cache::instance();
+        if ($cache) {
+            $cache->delete(Cache::key('fave:list-ids:notice_id:'.$notice_id));
+        }
+    }
 }