From: Evan Prodromou Date: Thu, 7 Apr 2011 20:24:56 +0000 (-0400) Subject: do a short-term cache of notice scope X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=3e4016b388181a1185fca496f89780de76875ea4;p=quix0rs-gnu-social.git do a short-term cache of notice scope --- 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.