Update code for subs to use common caching tools
This commit is contained in:
parent
33c13030e5
commit
235d458395
27
lib/subs.php
27
lib/subs.php
|
@ -58,22 +58,20 @@ function subs_subscribe_to($user, $other) {
|
||||||
|
|
||||||
subs_notify($other, $user);
|
subs_notify($other, $user);
|
||||||
|
|
||||||
if (common_config('memcached', 'enabled')) {
|
$cache = common_memcache();
|
||||||
$cache = new Memcache();
|
|
||||||
if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
|
if ($cache) {
|
||||||
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
|
if ($other->autosubscribe && !$other->isSubscribed($user) && !$user->hasBlocked($other)) {
|
||||||
if (!$other->subscribeTo($user)) {
|
if (!$other->subscribeTo($user)) {
|
||||||
return _('Could not subscribe other to you.');
|
return _('Could not subscribe other to you.');
|
||||||
}
|
}
|
||||||
if (common_config('memcached', 'enabled')) {
|
$cache = common_memcache();
|
||||||
$cache = new Memcache();
|
|
||||||
if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
|
if ($cache) {
|
||||||
$cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
|
$cache->delete(common_cache_key('user:notices_with_friends:' . $other->id));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subs_notify($user, $other);
|
subs_notify($user, $other);
|
||||||
|
@ -128,11 +126,10 @@ function subs_unsubscribe_to($user, $other) {
|
||||||
if (!$sub->delete())
|
if (!$sub->delete())
|
||||||
return _('Couldn\'t delete subscription.');
|
return _('Couldn\'t delete subscription.');
|
||||||
|
|
||||||
if (common_config('memcached', 'enabled')) {
|
$cache = common_memcache();
|
||||||
$cache = new Memcache();
|
|
||||||
if ($cache->connect(common_config('memcached', 'server'), common_config('memcached', 'port'))) {
|
if ($cache) {
|
||||||
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
$cache->delete(common_cache_key('user:notices_with_friends:' . $user->id));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue