mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
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
This commit is contained in:
parent
e31e998f3b
commit
dd4d8067f1
1 changed files with 17 additions and 12 deletions
29
src/applications/cache/PhabricatorCaches.php
vendored
29
src/applications/cache/PhabricatorCaches.php
vendored
|
@ -30,6 +30,7 @@ final class PhabricatorCaches {
|
||||||
static $cache;
|
static $cache;
|
||||||
if (!$cache) {
|
if (!$cache) {
|
||||||
$caches = self::buildSetupCaches();
|
$caches = self::buildSetupCaches();
|
||||||
|
$caches = self::addNamespaceToCaches($caches);
|
||||||
$caches = self::addProfilerToCaches($caches);
|
$caches = self::addProfilerToCaches($caches);
|
||||||
$cache = id(new PhutilKeyValueCacheStack())
|
$cache = id(new PhutilKeyValueCacheStack())
|
||||||
->setCaches($caches);
|
->setCaches($caches);
|
||||||
|
@ -45,12 +46,6 @@ final class PhabricatorCaches {
|
||||||
// In most cases, we should have APC. This is an ideal cache for our
|
// In most cases, we should have APC. This is an ideal cache for our
|
||||||
// purposes -- it's fast and empties on server restart.
|
// purposes -- it's fast and empties on server restart.
|
||||||
$apc = new PhutilKeyValueCacheAPC();
|
$apc = new PhutilKeyValueCacheAPC();
|
||||||
|
|
||||||
if (PhabricatorCaches::getNamespace()) {
|
|
||||||
$apc = id(new PhutilKeyValueCacheNamespace($apc))
|
|
||||||
->setNamespace(PhabricatorCaches::getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($apc->isAvailable()) {
|
if ($apc->isAvailable()) {
|
||||||
return array($apc);
|
return array($apc);
|
||||||
}
|
}
|
||||||
|
@ -60,13 +55,8 @@ final class PhabricatorCaches {
|
||||||
$disk_path = self::getSetupCacheDiskCachePath();
|
$disk_path = self::getSetupCacheDiskCachePath();
|
||||||
if ($disk_path) {
|
if ($disk_path) {
|
||||||
$disk = new PhutilKeyValueCacheOnDisk();
|
$disk = new PhutilKeyValueCacheOnDisk();
|
||||||
|
|
||||||
if (PhabricatorCaches::getNamespace()) {
|
|
||||||
$disk = id(new PhutilKeyValueCacheNamespace($disk))
|
|
||||||
->setNamespace(PhabricatorCaches::getNamespace());
|
|
||||||
}
|
|
||||||
|
|
||||||
$disk->setCacheFile($disk_path);
|
$disk->setCacheFile($disk_path);
|
||||||
|
$disk->setWait(0.1);
|
||||||
if ($disk->isAvailable()) {
|
if ($disk->isAvailable()) {
|
||||||
return array($disk);
|
return array($disk);
|
||||||
}
|
}
|
||||||
|
@ -183,4 +173,19 @@ final class PhabricatorCaches {
|
||||||
return $caches;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue