]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
blow subscriptions cache when the user deletes a notice
authorEvan Prodromou <evan@prodromou.name>
Sat, 20 Sep 2008 17:53:39 +0000 (13:53 -0400)
committerEvan Prodromou <evan@prodromou.name>
Sat, 20 Sep 2008 17:53:39 +0000 (13:53 -0400)
darcs-hash:20080920175339-84dde-e46d0e7b86e0752e8331cdfba26257b3ff9e601c.gz

actions/deletenotice.php
classes/Notice.php

index 0db7e0d1eec462d227c4a85f55d8ce09eff87bdb..64746283ae5103f18b06823d095412711eeafca4 100644 (file)
@@ -84,6 +84,9 @@ class DeletenoticeAction extends DeleteAction {
                        $replies->get('notice_id', $notice_id);
 
                        common_dequeue_notice($notice);
+                       if (common_config('memcached', 'enabled')) {
+                               $notice->blowSubsCache();
+                       }
                        $replies->delete();
                        $notice->delete();
                } else {
index 7c758061515f9d2a7a959c31dce73e1ddb548658..2d880f8cb39ad0324f3461e9106c84ea5d329985 100644 (file)
@@ -116,23 +116,27 @@ class Notice extends DB_DataObject
                # XXX: someone clever could prepend instead of clearing the cache
                
                if (common_config('memcached', 'enabled')) {
-                       $cache = new Memcache();
-                       if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
-                               $user = new User();
-               
-                               $user->query('SELECT id ' .
-                                                        'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
-                                                        'WHERE subscription.subscribed = ' . $notice->profile_id);
-
-                               while ($user->fetch()) {
-                                       $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
-                               }
-                               
-                               $user->free();
-                               unset($user);
-                       }
+                       $notice->blowSubsCache();
                }
                
                return $notice;
        }
+       
+       function blowSubsCache() {
+               $cache = new Memcache();
+               if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
+                       $user = new User();
+                       
+                       $user->query('SELECT id ' .
+                                                'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
+                                                'WHERE subscription.subscribed = ' . $this->profile_id);
+                       
+                       while ($user->fetch()) {
+                               $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
+                       }
+                       
+                       $user->free();
+                       unset($user);
+               }
+       }
 }