diff options
author | Evan Prodromou <evan@controlyourself.ca> | 2009-04-23 05:03:19 -0400 |
---|---|---|
committer | Evan Prodromou <evan@controlyourself.ca> | 2009-04-23 05:03:19 -0400 |
commit | 640628de2d593933e810b4785dfe38923b979713 (patch) | |
tree | 78787c9a248a0f757dffb622691c822d1b2cc4cd /classes/Notice.php | |
parent | 0dd90461cdc7aad26b6f855ca7f63988a4a74d74 (diff) |
A queuehandler for blowing caches offline
We add a queuehandler for blowing the memcached caches off-line. This
should speed up the processing of new notices.
Diffstat (limited to 'classes/Notice.php')
-rw-r--r-- | classes/Notice.php | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/classes/Notice.php b/classes/Notice.php index 5fa0d79a1..fbfeb9489 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -207,7 +207,11 @@ class Notice extends Memcached_DataObject # XXX: someone clever could prepend instead of clearing the cache if (common_config('memcached', 'enabled')) { - $notice->blowCaches(); + if (common_config('queues', 'enabled')) { + $notice->blowAuthorCaches(); + } else { + $notice->blowCaches(); + } } return $notice; @@ -271,6 +275,25 @@ class Notice extends Memcached_DataObject $this->blowGroupCache($blowLast); } + function blowAuthorCaches($blowLast=false) + { + // Clear the user's cache + $cache = common_memcache(); + if ($cache) { + $user = User::staticGet($this->profile_id); + if (!empty($user)) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id)); + if ($blowLast) { + $cache->delete(common_cache_key('user:notices_with_friends:' . $user->id . ';last')); + } + } + $user->free(); + unset($user); + } + $this->blowNoticeCache($blowLast); + $this->blowPublicCache($blowLast); + } + function blowGroupCache($blowLast=false) { $cache = common_memcache(); |