From dd4d8067f1b9c8758ec512e0c8534d653e230daa Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 13 Apr 2013 07:09:32 -0700 Subject: [PATCH] Add wait for setup issue fallback disk cache Summary: See D5657. Also cleans up the namespacing stuff a little bit. Test Plan: Disabled APC and verified that setup checks didn't run normally, but did run after restart and on `/config/issue/`. Reviewers: vrana Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D5658 --- src/applications/cache/PhabricatorCaches.php | 29 ++++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/applications/cache/PhabricatorCaches.php b/src/applications/cache/PhabricatorCaches.php index 6e9f5b7fc7..666329788f 100644 --- a/src/applications/cache/PhabricatorCaches.php +++ b/src/applications/cache/PhabricatorCaches.php @@ -30,6 +30,7 @@ final class PhabricatorCaches { static $cache; if (!$cache) { $caches = self::buildSetupCaches(); + $caches = self::addNamespaceToCaches($caches); $caches = self::addProfilerToCaches($caches); $cache = id(new PhutilKeyValueCacheStack()) ->setCaches($caches); @@ -45,12 +46,6 @@ final class PhabricatorCaches { // In most cases, we should have APC. This is an ideal cache for our // purposes -- it's fast and empties on server restart. $apc = new PhutilKeyValueCacheAPC(); - - if (PhabricatorCaches::getNamespace()) { - $apc = id(new PhutilKeyValueCacheNamespace($apc)) - ->setNamespace(PhabricatorCaches::getNamespace()); - } - if ($apc->isAvailable()) { return array($apc); } @@ -60,13 +55,8 @@ final class PhabricatorCaches { $disk_path = self::getSetupCacheDiskCachePath(); if ($disk_path) { $disk = new PhutilKeyValueCacheOnDisk(); - - if (PhabricatorCaches::getNamespace()) { - $disk = id(new PhutilKeyValueCacheNamespace($disk)) - ->setNamespace(PhabricatorCaches::getNamespace()); - } - $disk->setCacheFile($disk_path); + $disk->setWait(0.1); if ($disk->isAvailable()) { return array($disk); } @@ -183,4 +173,19 @@ final class PhabricatorCaches { return $caches; } + private static function addNamespaceToCaches(array $caches) { + $namespace = PhabricatorCaches::getNamespace(); + if (!$namespace) { + return $caches; + } + + foreach ($caches as $key => $cache) { + $ncache = new PhutilKeyValueCacheNamespace($cache); + $ncache->setNamespace($namespace); + $caches[$key] = $ncache; + } + + return $caches; + } + }