summaryrefslogtreecommitdiff
path: root/lib/subs.php
diff options
context:
space:
mode:
authorZach Copley <zach@controlyourself.ca>2009-01-23 01:20:00 -0800
committerZach Copley <zach@controlyourself.ca>2009-01-23 01:20:00 -0800
commit0ef33663ce0b3739e8e9eb3b9951dee5059c6b3b (patch)
tree179a9aaa7f7828489e93fca86ceeaa01b4d270a2 /lib/subs.php
parentb13374faa568e4e77478b9ffe5c800758ffdc3f3 (diff)
parent6b5fb0ab7d8c2e982052a48270e882e7f7379743 (diff)
Merge branch 'master' of ssh://zach@dev.controlyourself.ca/var/www/trunk
Diffstat (limited to 'lib/subs.php')
-rw-r--r--lib/subs.php34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/subs.php b/lib/subs.php
index 6fa1dcad3..0e7b9ded5 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -60,23 +60,22 @@ function subs_subscribe_to($user, $other)
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));
- }
- }
+ $cache = common_memcache();
+
+ if ($cache) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
+ }
+
if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
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));
- }
- }
+ $cache = common_memcache();
+
+ if ($cache) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
+ }
subs_notify($user, $other);
}
@@ -134,12 +133,11 @@ function subs_unsubscribe_to($user, $other)
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));
- }
- }
+ $cache = common_memcache();
+
+ if ($cache) {
+ $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
+ }
return true;
}