From d86f95479726d128883a67a14d5924460ec09e4b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 15 Sep 2008 03:15:00 -0400 Subject: [PATCH] subscriptions clear user with-friends cache, too darcs-hash:20080915071500-84dde-765c8c289d5cf7f71c2a49967bde4ecda28d9ea8.gz --- lib/subs.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/subs.php b/lib/subs.php index 383bfa0070..554647d442 100644 --- a/lib/subs.php +++ b/lib/subs.php @@ -43,15 +43,28 @@ function subs_subscribe_user($user,$other_nickname) { subs_notify($other, $user); + if (common_config('memcached', 'enabled')) { + $cache = new Memcache(); + if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + } + } + if ($other->autosubscribe && !$other->isSubscribed($user)) { if (!$other->subscribeTo($user)) { return _('Could not subscribe other to you.'); } + if (common_config('memcached', 'enabled')) { + $cache = new Memcache(); + if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id)); + } + } + subs_notify($user, $other); } return true; - } function subs_notify($listenee, $listener) { @@ -90,6 +103,13 @@ function subs_unsubscribe_user($user, $other_nickname) { if (!$sub->delete()) return _('Couldn\'t delete subscription.'); + if (common_config('memcached', 'enabled')) { + $cache = new Memcache(); + if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + } + } + return true; } -- 2.39.5