mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 21:02:41 +01:00
Cache viewer spaces
Summary: Ref T8575. Although we cache spaces as a whole, we don't cache viewer spaces. This can still do a lot of work if they have complex policies. Instead, cache them in the request cache. Test Plan: Saw this account for 37% of a page in produciton (303ms on on 835ms). Reviewers: btrahan Reviewed By: btrahan Subscribers: epriestley Maniphest Tasks: T8575 Differential Revision: https://secure.phabricator.com/D13324
This commit is contained in:
parent
af8ad58e6b
commit
984976ce20
1 changed files with 18 additions and 9 deletions
|
@ -5,6 +5,7 @@ final class PhabricatorSpacesNamespaceQuery
|
|||
|
||||
const KEY_ALL = 'spaces.all';
|
||||
const KEY_DEFAULT = 'spaces.default';
|
||||
const KEY_VIEWER = 'spaces.viewer';
|
||||
|
||||
private $ids;
|
||||
private $phids;
|
||||
|
@ -141,6 +142,11 @@ final class PhabricatorSpacesNamespaceQuery
|
|||
}
|
||||
|
||||
public static function getViewerSpaces(PhabricatorUser $viewer) {
|
||||
$cache = PhabricatorCaches::getRequestCache();
|
||||
$cache_key = self::KEY_VIEWER.'('.$viewer->getPHID().')';
|
||||
|
||||
$result = $cache->getKey($cache_key);
|
||||
if ($result === null) {
|
||||
$spaces = self::getAllSpaces();
|
||||
|
||||
$result = array();
|
||||
|
@ -154,6 +160,9 @@ final class PhabricatorSpacesNamespaceQuery
|
|||
}
|
||||
}
|
||||
|
||||
$cache->setKey($cache_key, $result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue