do a short-term cache of notice scope

This commit is contained in:
Evan Prodromou 2011-04-07 16:24:56 -04:00
parent 45ba33e2ac
commit 3e4016b388

View File

@ -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.