diff --git a/src/applications/cache/PhabricatorCaches.php b/src/applications/cache/PhabricatorCaches.php --- a/src/applications/cache/PhabricatorCaches.php +++ b/src/applications/cache/PhabricatorCaches.php @@ -117,6 +117,42 @@ } +/* -( Runtime Cache )------------------------------------------------------ */ + + + /** + * Get a runtime cache stack. + * + * This stack is just APC. It's fast, it's effectively immutable, and it + * gets thrown away when the webserver restarts. + * + * This cache is suitable for deriving runtime caches, like a map of Conduit + * method names to provider classes. + * + * @return PhutilKeyValueCacheStack Best runtime stack available. + */ + public static function getRuntimeCache() { + static $cache; + if (!$cache) { + $caches = self::buildRuntimeCaches(); + $cache = self::newStackFromCaches($caches); + } + return $cache; + } + + + private static function buildRuntimeCaches() { + $caches = array(); + + $apc = new PhutilAPCKeyValueCache(); + if ($apc->isAvailable()) { + $caches[] = $apc; + } + + return $caches; + } + + /* -( Repository Graph Cache )--------------------------------------------- */