From 3e4016b388181a1185fca496f89780de76875ea4 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 7 Apr 2011 16:24:56 -0400 Subject: [PATCH] do a short-term cache of notice scope --- classes/Notice.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index c908e7e3a7..c80e57dc97 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -2182,6 +2182,21 @@ class Notice extends Memcached_DataObject * @return boolean whether the profile is in the notice's scope */ function inScope($profile) + { + $keypart = sprintf('notice:in-scope-for:%d:%d', $this->id, $profile->id); + + $result = self::cacheGet($keypart); + + if ($result === false) { + $bResult = $this->_inScope($profile); + $result = ($bResult) ? 1 : 0; + self::cacheSet($keypart, $result, 0, 300); + } + + return ($result == 1) ? true : false; + } + + protected function _inScope($profile) { // If there's no scope, anyone (even anon) is in scope.