summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-09-20 13:53:39 -0400
committerEvan Prodromou <evan@prodromou.name>2008-09-20 13:53:39 -0400
commita64330b77c6f4607978e239f536f7d2a58185f3b (patch)
tree1d4430567bd015b180345e4c2af47ca4c1e2734a /classes/Notice.php
parentd53a4123f369087afd901073a4c865e9703ff698 (diff)
blow subscriptions cache when the user deletes a notice
darcs-hash:20080920175339-84dde-e46d0e7b86e0752e8331cdfba26257b3ff9e601c.gz
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php34
1 files changed, 19 insertions, 15 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 7c7580615..2d880f8cb 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -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);
+ }
+ }
}