summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <git@evanprodromou.name>2009-01-14 13:37:21 -0500
committerEvan Prodromou <git@evanprodromou.name>2009-01-14 13:37:21 -0500
commit235d458395248a04bc9e0ce94cef1c92beff9471 (patch)
tree65132fb3801028345f8ff6794a6279bbefee31dd
parent33c13030e559a3e89a66a788e5d496c7c4fba6cd (diff)
Update code for subs to use common caching tools
-rw-r--r--lib/subs.php27
1 files changed, 12 insertions, 15 deletions
diff --git a/lib/subs.php b/lib/subs.php
index a2699f7b9..483b2f78e 100644
--- a/lib/subs.php
+++ b/lib/subs.php
@@ -58,22 +58,20 @@ 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);
@@ -128,11 +126,10 @@ 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;