mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 03:01:11 +01:00
Cache application visibility in the request cache
Summary: Ref T8575. We check if users can see applications frequently, and caching on the Query isn't especially effective. Use the new Request cache instead. Test Plan: - Saw `/feed/` drop 7% (from ~830ms to ~770ms) on profiles. Reviewers: btrahan, avivey Reviewed By: avivey Subscribers: avivey, epriestley Maniphest Tasks: T8575 Differential Revision: https://secure.phabricator.com/D13321
This commit is contained in:
parent
30c4783c42
commit
8484adcffd
2 changed files with 22 additions and 20 deletions
|
@ -449,16 +449,27 @@ abstract class PhabricatorApplication
|
|||
$class,
|
||||
PhabricatorUser $viewer) {
|
||||
|
||||
if (!self::isClassInstalled($class)) {
|
||||
return false;
|
||||
}
|
||||
$cache = PhabricatorCaches::getRequestCache();
|
||||
$viewer_phid = $viewer->getPHID();
|
||||
$key = 'app.'.$class.'.installed.'.$viewer_phid;
|
||||
|
||||
return PhabricatorPolicyFilter::hasCapability(
|
||||
$result = $cache->getKey($key);
|
||||
if ($result === null) {
|
||||
if (!self::isClassInstalled($class)) {
|
||||
$result = false;
|
||||
} else {
|
||||
$result = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
self::getByClass($class),
|
||||
PhabricatorPolicyCapability::CAN_VIEW);
|
||||
}
|
||||
|
||||
$cache->setKey($key, $result);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
|||
private $workspace = array();
|
||||
private $inFlightPHIDs = array();
|
||||
private $policyFilteredPHIDs = array();
|
||||
private $canUseApplication;
|
||||
|
||||
/**
|
||||
* Should we continue or throw an exception when a query result is filtered
|
||||
|
@ -679,21 +678,13 @@ abstract class PhabricatorPolicyAwareQuery extends PhabricatorOffsetPagedQuery {
|
|||
* execute the query.
|
||||
*/
|
||||
public function canViewerUseQueryApplication() {
|
||||
if ($this->canUseApplication === null) {
|
||||
$class = $this->getQueryApplicationClass();
|
||||
if (!$class) {
|
||||
$this->canUseApplication = true;
|
||||
} else {
|
||||
$result = id(new PhabricatorApplicationQuery())
|
||||
->setViewer($this->getViewer())
|
||||
->withClasses(array($class))
|
||||
->execute();
|
||||
|
||||
$this->canUseApplication = (bool)$result;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return $this->canUseApplication;
|
||||
$viewer = $this->getViewer();
|
||||
return PhabricatorApplication::isClassInstalledForViewer($class, $viewer);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue