From 55a54facd5dbb24c2a90e54dcf156de4f82ed505 Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 6 Dec 2016 03:53:15 -0800 Subject: [PATCH] Use PhabricatorCachedClassMapQuery in Conduit method lookups Summary: Ref T11954. Depends on D16994. This implements the Conduit method cache described in that revision for a small global Conduit performance improvement. Test Plan: Verified Conduit has the same behavior at lower cost. See D16994 for details. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11954 Differential Revision: https://secure.phabricator.com/D16995 --- .../conduit/method/ConduitAPIMethod.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/applications/conduit/method/ConduitAPIMethod.php b/src/applications/conduit/method/ConduitAPIMethod.php index bc3f9e44e0..3a2cc6e30d 100644 --- a/src/applications/conduit/method/ConduitAPIMethod.php +++ b/src/applications/conduit/method/ConduitAPIMethod.php @@ -158,15 +158,20 @@ abstract class ConduitAPIMethod } public static function loadAllConduitMethods() { + return self::newClassMapQuery()->execute(); + } + + private static function newClassMapQuery() { return id(new PhutilClassMapQuery()) ->setAncestorClass(__CLASS__) - ->setUniqueMethod('getAPIMethodName') - ->execute(); + ->setUniqueMethod('getAPIMethodName'); } public static function getConduitMethod($method_name) { - $method_map = self::loadAllConduitMethods(); - return idx($method_map, $method_name); + return id(new PhabricatorCachedClassMapQuery()) + ->setClassMapQuery(self::newClassMapQuery()) + ->setMapKeyMethod('getAPIMethodName') + ->loadClass($method_name); } public function shouldRequireAuthentication() {